How to extract a string between 2 strings using regexp ?

skumars1808
Tera Contributor

I need to extract the version of CIs from the descriptin field of the CI. The description field will look line this:

jfshfshmn  vshshjij ijjf0sfk, jhg9s, uishf9, Version 23.45.5679(E), fhuisfhaho

fsihsfpoh:hsfhsij

huisgfha:uhauhju

hoajfphnsiovj osvjis 

I need to extract the the string between Version and ",". How can I do it using regular expression?

Please help.

4 REPLIES 4

Pranav Bhagat
Kilo Sage

Hi skumars1808

Try this

(?:(\d+)\.)?(?:(\d+)\.)?(?:(\d+)\.\d+)

 

If you also want (E)

(?:(\d+)\.)?(?:(\d+)\.)?(?:(\d+)\.\d+.{3})

 

Use this website and try

https://regexr.com/

Regards

Pranav

Hi skumars1808

Hope you are doing good.

Is this question resolved or you need some more assistance?

if your query is resolved then please mark the correct response so that this thread can be closed.

Regards

Pranav

Willem
Giga Sage
Giga Sage

This works:

var inputStr= "jfshfshmn  vshshjij ijjf0sfk, jhg9s, uishf9, Version 23.45.5679(E), fhuisfhaho fsihsfpoh:hsfhsij huisgfha:uhauhju hoajfphnsiovj osvjis "
var re = /Version (.*?)\,/gi;
var outputStr = re.exec(inputStr)[1];

 

find_real_file.png

Willem
Giga Sage
Giga Sage

Hi @skumars1808 

Hope you are doing well.

Is your question resolved? Or do we need to follow-up on this?

Please mark the answer as correct if it solves your question. This will help others who are looking for a similar solution. Also marking this answer as correct takes the post of the unsolved list.
Thanks.

Kind regards,

Willem