I need to create a search which extract last word of the URL as below:-
https://hostname/bs/cf/webservice/WordtoExtract ...
Please let me now how to extract last word of above URL i.e WordtoExtract.
Lots of ways to solve this. Positive lookbehind is worth exploring!
| makeresults
| eval url="https://hostname/bs/cf/webservice/WordtoExtract"
| rex field=url "(?<=\/)(?<theWord>\w+)$"
Regex101: https://regex101.com/r/eslxJR/1
Like this:
... | rex field=url "\/(?<lastURLword>[^\/]+)$"
Hi
Try this too
| makeresults
| eval url="https://hostname/bs/cf/webservice/WordtoExtract"
| eval temp=split(url,"/")
| eval output = mvindex(temp,mvcount(temp)-1)
| makeresults
| eval url="https://hostname/bs/cf/webservice/WordtoExtract"
| eval output = mvindex(split(url,"/") ,-1)
That's enough.
@bsaujla131984 ,
Try
|rex field=URL "\/(?<last_word>[^\/]*)$"