I'm using evil mode on Emacs2 27.1 on OSX. My goal is to search and replace some text containing unicode strings using either of emacs' replace-regex or vim's search/replace functionality.
To begin with, let me showcase the example in vim without the use of unicode characters:
My text file has plenty of markers (let's say the unicode char ।
i.e U2404) and I need to wrap the marker along with its preceding word into \mbox{}
E.g input text
This is a string।
This is another (string) ।
One more example string here ।
This regex does the job for me in vim: %s/\((\?\w*)\?\)\s*।/\\mbox{\1 ।}/g
Output
This is a \mbox{string ।}
This is another \mbox{(string) ।}
One more example string \mbox{here ।}
Now, onto solving the real problem with unicode chars. Sample text:
This is a नमस्ते।
This is another (नमस्ते) ।
One more example string नमस्ते ।
The above vim regex does not work because \w
does not match unicode chars. However, I can use \S
, which denotes any non-space character, in the regex to apply the search/replace with pattern %s/\((\?\S*)\?\)\s*।/\\mbox{\1 ।}/gc
This regex does not work in emacs' evilmode. Is there such a thing as \S
in emacs' regex repertoire? I glanced through emacs' regex syntax and couldn't find anything.
What's the regex to use to obtain the same results as with the vim command %s/\((\?\S*)\?\)\s*।/\\mbox{\1 ।}/gc
?