Youra In
Youra In

Reputation: 11

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 [^\/]*[a-z] * but i have no idea what is next step. can somebody help me?

Thanks

Upvotes: 1

Views: 583

Answers (2)

RichG
RichG

Reputation: 9916

In Splunk, this should do it.

... | rex field=foo "(?<word>\w+)" | ...

Upvotes: 1

Atahan Atay
Atahan Atay

Reputation: 363

String before = "...";
String after = before.replaceAll("[/](\w+).*", "$1");

And you can use "after".

(Java solution)

Upvotes: 0

Related Questions