سؤال

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.

هل كانت مفيدة؟

المحلول 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.

نصائح أخرى

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
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top