简体   繁体   中英

regex match between characters

the strings are like

/fruit] 

/animal/lion

/plant/flower/rose

and i want to get only first word without slash and blacket which means fruit, animal, plant.

I did until [^\/]*[az] * but i have no idea what is next step. can somebody help me?

Thanks

In Splunk, this should do it.

... | rex field=foo "(?<word>\w+)" | ...
String before = "...";
String after = before.replaceAll("[/](\w+).*", "$1");

And you can use "after".

(Java solution)

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM