0

My text is as below:

• heading 1\n» text_string: text_string\n» text_string: text_string\n• heading 2\n» text_string: text_string\n» text_string: text_string

I want to change \n» text_string: into \n» text_string\n - so the text should be displayed in my app as:

• heading 1
  » text_string
    - text_string
  » text_string
    - text_string
• heading 2
  » text_string
    - text_string
...

How can I use RegEx (Grep) to find \n» text_string: and replace it by \n» text_string\n -?

(I'm using TextWrangler).

Thank you very much.

ruakh
  • 175,680
  • 26
  • 273
  • 307
Niamh Doyle
  • 1,909
  • 7
  • 30
  • 42

1 Answers1

1

if you want to change this:

• heading 1 » text_string: text_string » text_string: text_string • heading 2 » text_string: text_string » text_string: text_string

to this:

• heading 1 » text_string - text_string » text_string - text_string • heading 2 » text_string - text_string » text_string - text_string

I rather that you do something like this

text.replace(/:\stext_string(\n|$)/ig,"\n\t- text_string\n");

that is a normal regexp in javascript, I hope that help you somehow

MARP
  • 581
  • 1
  • 12
  • 19
  • I still don get used to the text formatting, but I hope that you understand – MARP Jun 13 '12 at 18:05
  • I'm not sure he actually has "text_string" in his file that many times, although it wasn't made clear. – eqzx Jun 13 '12 at 18:22
  • Thanks a lot. By 'text_string' I mean any word or series of words. Unfortunately, I'm only used to TextWragler or Notepad ++, so don't know what to do with your prompt. – Niamh Doyle Jun 13 '12 at 18:33
  • hmmm I see, I thought that you was using javascript or something, my bad – MARP Jun 13 '12 at 21:00
  • Provided: - @mechdeveloper did correctly (re)format both of your original and expected text, - you really want just to replace `:` with `\n - ` -- and - there are no additional colons in your text_strings: How is the result of a TextWrangler search for `:` and replace with `\n - ` different from what you are looking for? – Abecee Nov 04 '14 at 22:51