Question

I need help with a GREP expression to find and replace a variable group of words. The sentence always starts with the same two words (Bold italicized) and always ends with a (colon), but the bit in the middle varies. So I need to search for:

Bold italicized then any string of words then :

ie. starts with "Bold italicized", then any group of words, ends with ":"

For example:

Bold italicized May 6, 2010:

I will then apply some formatting to that text. Thank you.

Était-ce utile?

La solution 2

This should do it, although this is a pretty simple one, so it seems like you should have been able to come up with this yourself, even as a beginner.

^Bold italicized.+?:

If you want to learn a little bit more about how to use GREP, I would recommend the InDesign GREP reference.

Autres conseils

The right tool do do this is not but :

EXAMPLE in a shell :

$ cat file.txt 
Bold italicized foo bar:
Bold italicized qux:
$ sed 's/^Bold italicized\(.*\):/do something with "\1"/g' file.txt
do something with " foo bar"
do something with " qux"
$ 

NOTE

  • you will find tons of examples and documentation here or here
  • the basic sed substitution command is s/regex/substitution/modifier
  • that use regex, I use ^ that means beginning of line, and \( \) to make a capture
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top