2

I have a text file to process, with huge number of lines like this:

000AA Sylvester Stallone

000AD Demi Moore

I would add for each word, a single quotation mark like this:

'000AA' 'Sylvester' 'Stallone'

'000AD' 'Demi' 'Moore'

I suppose that the best(and maybe the only way?) is to use notepadd++ find/replace with regex, but unluckily I have not enough knowledge. Please, there is someone can help me? This will be a huge time saver help!!

1
  • 1
    Are there any other lines you do not want to touch? If yes, what makes the ones you want to modify specific (and thus we could match them with some pattern)? Did you try anything at all? Do you know how to use a regex-based search and replace in Notepad++? I ask because if I say use \S+ and replace with '$0', is that enough? Commented Dec 15, 2015 at 0:07

1 Answer 1

13

Just search for

([^\s]+) 

(Matches every character but any whitespace)

and replace it with

'$1'

(replaces the match with the same string, but leading and trailing ')

Sign up to request clarification or add additional context in comments.

8 Comments

Thanks a lot, works like a charm!! just another little question can I add open/close parenthesis at the start/end of each line with regex? like this: from '000AA' 'Sylvester' 'Stallone' to ('000AA' 'Sylvester' 'Stallone') ps. in one regex would be the perfection :)
Replace first character with itself followed by opening bracket: search: ^(.), replace: \($1 - Replace last character with itself followed by closing bracket: (.)$ -> $1\)
Sorry I don't understand the last regex.could you explain me better? I must replace the old regex or add this last one? Thanks a lot!
it's Independent regex'. You have to run three: First, add quotes, second add opening bracket, third add closing bracket. (last one means: search (.)$, replace: $1\)
well actually the last two can be merged: search ^(.*)$, replace: \($1\)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.