Page 1 of 1

Apply changes around various text

Posted: Fri Feb 02, 2007 5:37 pm
by predaina
I need to add html code around various text.

existing code:

Code: Select all

</div>by: author name

The author name is usually different for each file and is normally at the end of the line.
The replace should format it like this:

Code: Select all

</div><p>by: author name</p>

or even better as

Code: Select all

</div>
<p>by: author name</p>


Sometimes the text is preceeded by more text, such as:

Code: Select all

</div>by: author name Start of other text I don't change

The replace should format it like this:

Code: Select all

</div><p>by: author name</p><p>Start of other text I don't change


Even better like this:

Code: Select all

</div><p>by: author name</p>
<p>Start of other text I don't change



The RE's are making me crazy...

Thank you in advance.

Re: Apply changes around various text

Posted: Fri Feb 02, 2007 10:57 pm
by Abacre
predaina wrote:I need to add html code around various text.

existing code:

Code: Select all

</div>by: author name

The author name is usually different for each file and is normally at the end of the line.
The replace should format it like this:

Code: Select all

</div><p>by: author name</p>

or even better as

Code: Select all

</div>
<p>by: author name</p>


Go to main menu - Action - Options - Batch Replace
check "Modifier S"
uncheck "Modifier G"

Go to Batch replace tab, check on "Use regular expressions".
Put into the grid, search for:
</div>by:(.*)\r\n

Replace with:
</div>\r\n<p>by:$1</p>\r\n

That's all I verified it works perfectly.

predaina wrote:Sometimes the text is preceeded by more text, such as:

Code: Select all

</div>by: author name Start of other text I don't change

The replace should format it like this:

Code: Select all

</div><p>by: author name</p><p>Start of other text I don't change


Even better like this:

Code: Select all

</div><p>by: author name</p>
<p>Start of other text I don't change


This is possible too. But how do you define what is the author name
and what is the text after that? What is the separator?
I mean are you sure you have author name in the format like this:
First Name Last Name ?
Or is the author name always in lower case?
Or does the "other text" start with a capital letter?

Posted: Fri Feb 02, 2007 11:11 pm
by predaina
This is possible too. But how do you define what is the author name
and what is the text after that? What is the separator?
I mean are you sure you have author name in the format like this:
First Name Last Name ?
Or is the author name always in lower case?
Or does the "other text" start with capital char?


We can only assume that the author's name is firstname lastname. The articles were not well formatted.

We can also assume that the "other text" starts with a capital letter.

Thanks in advance.

Posted: Fri Feb 02, 2007 11:23 pm
by Abacre
Ok. Suppose that first name and last name are separated by space:
The regular expression will be:
Search for:
</div>by:\s+(\S*\s+\S*)\s+(.*)\r\n
Replace with:
</div>\r\n<p>by: $1</p>\r\n<p>$2\r\n

Now if you want to further refine RE and supposing that "other text"
starts with a capital letter:

Search for:
</div>by:\s+(\S*\s+\S*)\s+([A-Z].*)\r\n
Replace with:
</div>\r\n<p>by: $1</p>\r\n<p>$2\r\n

Posted: Sat Feb 03, 2007 8:58 pm
by predaina
Perfect, thank you so much. With this I am able to create other RE's and have a better understanding of them.

A support forum like this makes me glad I purchased your product.