I would really appreciate it if someone could provide me with a regular expression to do the following.
The rules:
- all words except ‘and’ need wrapping with SYN()
- the String can contain an unlimited amount of words, the same rules appyl to all of the words in the String.
Examples:
‘London and toilet’ to become ‘SYN(London) and SYN(toilet)’
’10 and Mayfield and London’ would become ’10 and SYN(Mayfield) and SYN(London)’ (10 is not wrapped as it is not a word)
The reason for my question is that I am using an ORACLE thesaurus and the SQL syntax requires words to be wrapped with SYN().
I was initially going to split all of the words up in the String by searching for spaces and then using String.format(SYN(%s), ‘London’) to wrap the word in SYN() but I knew that all of this could be done with a regular expression and I thought that there would be some eager regular expression fanatics who would help me out.
Try
output