Jump to content
Sign in to follow this  
FranzB

regular expressions split text with different options

Recommended Posts

I need  to  extract a word from a text  file,  the word is defined like 

MyWord (  ......... .    );   

MyWord(      .....) 

MyWord ; 

MyWord;

 

Can I extract MyWord with one regex expression or do I need 2 spilt lines of code and compare ? 

 

list := TRegEx.Split(Input_Text, '(' );

Share this post


Link to post

From what you wrote, trivial Pos('MyWord', s) will do the job. Or you should define conditions more strictly. What could be inside brackets? What chars MyWord contains? You seem trying to extract function calls from a source file. Don't forget about comments if they're allowed

Edited by Fr0sT.Brutal

Share this post


Link to post

MyWord is the string i want to extract, in the brackets come a list of numbers  or strings 

LongList ( 1,2,3,4,5)

Towns ( Paris, London, NY,  Berlin)

 

 

later I also need to extract the  text between the brackets  and need to port this code  to delphi 

 

txt = "Town (my) simple test";
reg = /((.*))/;
Ausgabe = txt.match(reg);

 

 

 

Edited by FranzB

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×