I’m not sure if this is a regex question, but i need to be able to grab whats inside single qoutes, and surround them with something. For example:
this is a 'test' of 'something' and 'I' 'really' want 'to' 'solve this'
would turn into
this is a ('test') of ('something') and ('I') ('really') want ('to') ('solve this')
Any help you could provide would be great!
Thanks!
What I did here is use toe
replaceAll()method which searches for all matches for regex"'[^']*'"and replaces them with regex"($0)".The pattern
"'[^']*'"matches all substrings that start and end with a single quote ('), and between them are any characters, except another single quote ([^']), and those can appear any number of times (*). Replacing those with"($0)"means taking every match ($0) and wrapping it with parenthesis.