Using mulitple wildcard for replace

General discussions about Advanced Find and Replace
Post Reply
predaina
Posts: 5
Joined: Fri Feb 02, 2007 4:49 pm
Location: United States of America

Using mulitple wildcard for replace

Post by predaina »

Hi,

Thank you for your help on my last question. I was doing fine until this.

I want to capture the author name from the <p>by: fname lname</p> line and place into the Author meta tag.

My existing html document: (the jave code is one line and no special characters).


<meta name="Author" content="someone @ the-internet.com" />
<meta name="Robots" content="noindex,nofollow" />
<link rel="stylesheet" href="../stylesheet.css" type="text/css" />
</head>
<script language="JavaScript1.2">
function run()
{
some java code here
}
</script>
<body>
<!-- Article Start -->
<h1>10 Article Writing Quirks</h1>
<!-- Author -->
<p>by: Nicholas Dixon</p>
<p>Much has been touted about... rest of the file



This is the RE I tried:

search for: <meta name="Author" content="(.*)" />\r\n(.*)<!-- Author -->\r\n<p>by: (.*)</p>\r\n

replace with: <meta name="Author" content="$3" />\r\n$2<!-- Author -->\r\n<p>by: $3</p>\r\n


The result is:
<meta name="Author" content="Nicholas Dixon</p>
<p>Much has been touted about... rest of the file


I tried modifiers S,G and S,G,M.

You know, I turned off the S and M modifier and it worked! So no need to reply - thanks

Thanks in advance.
Thanks,
Tim

Abacre
Site Admin
Posts: 1223
Joined: Mon Jan 31, 2005 5:32 pm

Re: Using mulitple wildcard for replace

Post by Abacre »

predaina wrote:This is the RE I tried:

search for: <meta name="Author" content="(.*)" />\r\n(.*)<!-- Author -->\r\n<p>by: (.*)</p>\r\n

replace with: <meta name="Author" content="$3" />\r\n$2<!-- Author -->\r\n<p>by: $3</p>\r\n


The result is:
<meta name="Author" content="Nicholas Dixon</p>
<p>Much has been touted about... rest of the file



I have verified your RE: it's correct and it's working.
The only question is to setup correct modifiers:

State of Modifier M: does not matter for your case. The same for
modifiers: I, X and E.

But you have to turn on Modifier S. So .* in \r\n(.*)<!-- Author -->
will be used across several lines of text.

And you have to turn off Modifier G. That's why you have got the
result (text in red above). Because it was taken in greedy mode.
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

predaina
Posts: 5
Joined: Fri Feb 02, 2007 4:49 pm
Location: United States of America

Post by predaina »

Thank you again Roman, I am slowly starting to understand how this tool can be very powerful (and dangerous if you're not watching). 8)

Best regards!
Thanks,
Tim

Abacre
Site Admin
Posts: 1223
Joined: Mon Jan 31, 2005 5:32 pm

Post by Abacre »

It can be even more powerful with Modifier E turned on.
You may convert text into upper or lower case, wrap text, compare text
and execute some other useful functions.
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

Post Reply