Regular match between a line and a carriage (^), eliminating the appearance of a carriage (^)

Here are the data

[StupidHtml]: AZaz.-09^abcdabcd^a^a^

I need a regular expression to extract data between [StupidHtml]:and the first occurrence^

I am currently using

(?<=\[StupidHtml\]\:)(.*)(?=\^)  

But this leads to:

AZaz.-09^abcdabcd^a^a

I need to reach Azaz.-09

+5
source share
3 answers

Try the following:

(?<=\[StupidHtml\]\:)(.*?)(?=\^)
+1
source

Make your regex less greedy by using (.*?)instead (.*):

\[StupidHtml\]\:(.*?)\^
+2
source

.will match any character, even ^. You must exclude it from the corresponding class.

Try (?<=\[StupidHtml\]\:)([^\^]*)(?=\^)

0
source

All Articles