I am currently new to Regex, can someone help me with it? So the text that I have is the following:
yolo _time<=$info_max_time$ (index=* OR index=_*) $threat_match_value$ [search _time=2022-09-26T11:17:12.000-07:00 index=threat_activity | head 1 | `makemv(orig_sourcetype)` | rename orig_sourcetype as sourcetype | mvexpand sourcetype | return 100 sourcetype]
I want a regex that finds out the string for example, given that it starts with a space and match ends when it gets the provided substring
_time<=$info_max_time$
So I have $info_max_time$, I want to search for the string which starts with a space and ends with $info_max_time$. Now in between it can have any characters, _, = or <= or >="
You may use:
\s\S+?\$info_max_time\$
Demo .
Details:
\s
- A whitespace character. \S+?
- One or more non-whitespace characters (non-greedy quantifier). \$info_max_time\$
- Match "$info_max_time$" literally. Note that \s
will match any whitespace characters (eg, tab, EOL, etc.). If you're only interested in the ASCII space (AKA %20
), you may use the following instead:
[ ][^ ]+?\$info_max_time\$
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.