0

I want to add tags to selected text.

Tried recording a macro that searches for ^ and replaces it with <strong> and also looks for $ and replaces it with </strong>. Works great when the word/phrase is at the beginning of a line...

but when I have a word that's within a paragraph or is preceded by whitespace it fails.

Any ideas? Thanks in advance.

glomad
  • 5,539
  • 2
  • 24
  • 38
  • Was your question answered below? If so, please mark one of the answers as "Accepted". See this page for more details: http://stackoverflow.com/help/accepted-answer – hargobind Nov 05 '13 at 21:55

3 Answers3

1

You might want to check into http://www.regular-expressions.info/. They've got a wealth of information about all the different regex variants out there.

Offhand, have you tried searching for \b or \B? Those two sequences test for word boundaries (rather than line boundaries).

AndyV
  • 3,696
  • 1
  • 19
  • 17
1

@SpikeX's answer is close...

Add the following to your Find/Replace dialog:

Find what: (.+)

Replace with: <strong>\1</strong>

[x] Selected text

Click the "Replace All" button, then save your macro.


Edit: Under the Configure menu > Preferences, click on the Editor tab and make sure to check "Use POSIX regular expression syntax". Otherwise, you'll need to modify the "Find what" expression to \(.+\)

hargobind
  • 582
  • 2
  • 20
0

I'm not familiar with TextPad, but you might give this a try, it could work:

  • Select your text.
  • Find (.*), but limit it to only the selection, not the entire document.
  • Replace with <strong>$1</strong>, or \1, or whatever the replacement syntax is in TextPad.

I think this is contingent upon TextPad's ability to find a regular expression within the current selection, so if that's not possible, I think you're out of luck, and you'll have to try another application.

qJake
  • 16,821
  • 17
  • 83
  • 135