Reputation: 191
I want to match the Property Name
and Property value
in the string below
#Property Name : Property Value
The Property Name
and Property Value
are single/multi-worded sentence with numbers and spaces only. No special characters in them.
I tried with (?<=#)(.*):(.*?)
but it is not working. I read through many of the questions in this website and tried them, but none seemed to work.
I expect the answer to use QRegExp
(RegEx class of Qt) of qt4
Upvotes: 0
Views: 703
Reputation: 38062
IMO this is better:
^#\s*([^:]+?)\s*:\s*(.*?)\s*$
https://regex101.com/r/pW3wV4/3
See this to why my solution is better (same reg exp but more test cases).
Upvotes: 1
Reputation: 1944
Try the following regex
^#([a-zA-Z0-9 ]*) : ([a-zA-Z0-9 ]*)$
demo here: https://regex101.com/r/gS7rF5/2
Upvotes: 1