Regular Expression Searching

Z

Zachary Turner

Hi guys,

I am wondering if someone can help me out with a regular expression search.

I have a "text database" sort of, where rows are separated by newlines, and
columns are separated by columns. But I have an old format that I'm
converting from to this new format, and I need a quick way to add blank
fields in where there aren't enough. The old format looks like this:

'EnglishText JapaneseText',
'EnglishText JapaneseText',
....

I want to convert it to something like this:

'EnglishText, , JapaneseText',
'EnglishText, , JapaneseText',
'EnglishText, , JapaneseText',
....

There's a one-to-one correspondence between the rows, except that now I need
to insert the blank field. I am looking for a regular expression that I can
use to match this and replace the single space in the middle of the original
thing, with comma-space-comma-space. I think that using Word's regular
expression searching is the way to go, but I can't figure out how to get the
right Find string, or how to put in a Replace string that allows me to
replace the string with part of what it found. for example, it might find
"abcde ", which it should replace with "abcde, , " but then later it might
find "fdsjl ", which it should replace with "fdsjl, , " etc. By the way, in
the English text pretty much any character can appear. I basically want to
match all the way up until it finds a space followed by Japanese text. All
the examples I've tried match the same thing many times. For example, if
the line is "claim <JapaneseText>", and I try to match some english text
followed by a space, it will match "claim " "laim " "aim " "im " "m " etc.
I just want it to match the longest possible one and then move on.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top