Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regex to match everything between a string and a caret (^) excluding occurrence of caret (^)

Here is the data

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

I need a regex to retrieve data between [StupidHtml]: and first occurrence of ^

Currently I am using

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

But that results in:

AZaz.-09^abcdabcd^a^a

I need to achieve Azaz.-09

like image 660
HawkEye13 Avatar asked Oct 22 '22 14:10

HawkEye13


1 Answers

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

\[StupidHtml\]\:(.*?)\^
like image 143
Blender Avatar answered Oct 27 '22 21:10

Blender