0

It seems simple enough but I can't get it done. My text file looks like this :

Johnson Cary, 2009, This important article, 109 pages.

Smith Tom, 2003, Much ado about nothing: a study, 89 pages.

I need this :

Johnson Cary%2009%This important article%109 pages.

Any special character unlikely to appear in text will do. The end goal is to end up with a .csv then a .xls file.

I am using

^\([^,]+\)\([,]\)

to find the first occuring comma but when I try to replace with

 \1 %

it does not work, nor any kind of close combination of that sort for that matter.

Any help will be dearly welcome!

Thank you much in advance.

2
  • That wouldn't replace more than one comma, but it works just fine for the first one. In what way is it not working for you? Note that this may not be a safe approach (are escaped/quoted commas permitted in the data in any format?). Commented Oct 16, 2014 at 22:41
  • A tip when working with regexps is to build them with a visual feedback: wikemacs.org/wiki/Regexp Commented Oct 17, 2014 at 9:50

1 Answer 1

1

Replace this:

^\([^,]*\), \([^,]*\), \([^,]*\), \(.*\)$

with this:

\1%\2%\3%\4

to get the correct result.

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

1 Comment

Wow! The computer worked its magic! I should have asked 3 hours ago. Thank you, thank you. Love from Paris.

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.