I think I've nearly got this figured out but I cant for life of me figure out why its removing the first part of "little rock"
Heres the string I'm working with:
"<Telerik.Sitefinity.GeoLocations.Model.Address>\n <City>Little Rock</City>
Here's my RegEX:
/(?<=>[^\\n]). ?(?=\<)/gm
And here's my results so far:
ittle Rock
I'm trying to capture the text between the angled brackets but also ignore any \n values. Any help would be greatly appreciated.
CodePudding user response:
You can use
(?<=>(?!\\n))[^<>]*(?=<)
See the regex demo. Details:
(?<=>(?!\\n))
- a positive lookbehind that requires (immediately to the left of the current location) a>
char not immediately followed with\n
two-char sequence to appear immediately to the left of the current location[^<>]*
- zero or more chars other than<
and>
(?=<)
- a positive lookahead that requires<
char at the right of the current location.
Variations
(?<=>(?!\\n)).*?(?=<)
(?<=>(?!\\n))[^<>]*