How split string in a string with numbers?

sitajony

Active Member
Licensed User
Hi, I've some problems...
I've a string who contain a calcul and words...

Example:

"word+5*word2"

I would like know each word and split it from the string for replace it by a value like a variable...

I can't know what will be the words so I can't simply type StrReplace()...
This'll can contain also function names:

"word()+5*word2"

I've to know if it's a function or just a Word...
I know how do it but I'm affraid the code length that I can write. Maybe there's a best way for do it...
Tell me if you don't understand!
I've no source to Upload sorry...
Thanks for your help!

Edit:
Each words are the TextBox names who contain values...
 
Last edited:

berndgoedecke

Active Member
Licensed User
Longtime User
Regular expression

Hello Sitajony,
did you ever try to match the words with RegularExpressions(RegEx Library) ?
You can distinguish letters and numbers with it.
It's just an idea.
Sorry, I also have no Source to load up.

Best regards

berndgoedecke
 

mjcoon

Well-Known Member
Licensed User
I would like know each word and split it from the string for replace it by a value like a variable...

I'm not sure that I understand, and this is not a real answer, more a hint for Googling...

But it looks very like building a compiler. Historically this could be done using two tools called "lex" and "yac". Lex split up an input string into "tokens" using rules which typically distinguished words (names or tags) from punctuation. Then yacc operated on those tokens using the definition of the syntax of the language.

HTH, Mike.
 

sitajony

Active Member
Licensed User
Thanks for your replies, I test your ideas...
For the function names I tried to search "(" and search before this while it's a letter and found the function name and from ( to ) too... Maybe there's a better way... For variable I found...
I tell you if I successful...
 
Top