Page 1 of 1

newb needs help: Simple regular expression

Posted: Thu Jul 24, 2003 12:46 pm
by nyc2002
Hello:

a bit of a newb when it comes to regular expressions -- so forgive me if this is covered elsewhere -- i did a search on this forum but could not find any info.

I need to replace some <br> tags that have random spacing, and also comes in various numbers, but always follow text, and end with a comment tag.

so for example, a document might have:
Some text<br>
<br>
<br>
<!-- comment tag -->
or
Some text <br>
<br>
<br>
<br>
<!-- comment tag -->
and the <br> might have a tab space in front of it as well.

any ideas ?

I know the [[:space:]] command should help, but using it to find more than one space hasn't worked for me ...

thanks.

Posted: Thu Jul 24, 2003 1:03 pm
by MudGuard
Replace

Code: Select all

^\t*<br>\n<!--
by

Code: Select all

<!--
repeat until nothing is found...

Posted: Thu Jul 24, 2003 4:20 pm
by nyc2002
thanks MudGuard:

but I can't seem to get it to work. It doesn't actually find anything.

I'm looking at one of my documents, and it has:

Code: Select all

	12401<br>
				<br>
			<br>
			<br>
  	      	<br>
            <!-- comment tag -->
I have regular expression checked off :)

does the comment tag need to be escaped perhaps ?

thanks.

Posted: Thu Jul 24, 2003 7:01 pm
by MudGuard
You did not mention that the comment might have tabs before it as well.

Search for

^\t*<br>\n\t*<!--

Posted: Thu Jul 24, 2003 9:33 pm
by nyc2002
MudGuard --

feel free to ignore this post, since you have offered more than I deserve :)

but I still can't get this damn thing to work, and I have 400+ files I need to update.

Just so you don't think I'm totally crazy, I'm attaching the file with the sample.

http://www.polystager.com/sample.txt


many thanks!

Posted: Thu Jul 24, 2003 9:46 pm
by MudGuard
ah, mixed tabs and spaces...

Try

Code: Select all

^[\t ]*<br>\n[\t ]*<!--

Posted: Thu Jul 24, 2003 9:53 pm
by nyc2002
thanks !!

much appreciated.