Regex pattern(parent): ([Az]{1,})-([az]{1,})=
this pattern finds out(eg:mid-night).
Regex pattern (child): Need to Know regex pattern for finding words(midnight) and (mid night).
I need Regex pattern for finding those words.
[az]+ ?[az]+
matches both midnight
and mid night
.
Middle " ?"
matches zero or one space characters.
I assume you're using the parenthesis to regroup the words after. I'm not sure what you're looking for with regard to including capitalization. ([Az]+)[ ]?([az]+)
will match midnight
, MIDNIGHt
, mid night
, Mid night
, MID night
, etc.
If you're looking to match mid-night as well, use ([Az]+)[- ]?([az]+)
.
I'm not sure what your aim is but this regex should work:
([A-z]{1,})[ ]?([a-z]{1,})
Or try this one to match also your parent pattern:
([A-z]{1,})[ ]?-?([a-z]{1,})
But still I would' recommend to just split the parent match using - , so:
string parentMatch = "mid-night";
string[] words = parentMatch.Split('-');
Then you would get following output words = { "mid", "night" }
, so you could either concatenate them or not
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.