Is this possible with regular expressions? (tricky)
Posted: Mon Apr 10, 2006 10:01 pm
I have a .txt file with a lot of paragraphs. (NOTE: the paragraphs are separated by one PARAGRAPH MARK)
Can I do the following: I know exactly the beginning of each paragraph, and I know how it ends (obviously, with the paragraph mark).
Can I APPEND some text after the PARAGRAPH MARK?
(context for advanced users: I want to add a closing tag in xml files)
I will illustrate this:
Example of a paragraphs:
(note that these are actually xml tags you will see)
<name>blablablalblabla, text ended by a PARAGRAPH MARK
<contact>blablablabla, text ended by a PARAGRAPH MARK
Remember: I want to add the closing tags.
I want to search for:
<name>, then some arbitrary text (characters as well as numbers, even punctuation etc...) and then the PARAGRAPH MARK
THEN,
I want to append </name> after the PARAGRAPH MARK.
The same goes for <contact>:
append </contact> after the PARAGRAPH MARK.
How do I setup such a SEARCH AND APPEND? My problem is twofold:
1. How do I express the paragraph mark: is this a carriage return, a line feed, a new line?
2. I know that a . stands for one arbitrary character. How do I formulate multiple arbitrary characters?
I am sure this can be done, but I'm losing my hair because I'm keep pulling them out! I can't figure this out.
Can somebody give some advice. It would be really appreciated!
Levil
Can I do the following: I know exactly the beginning of each paragraph, and I know how it ends (obviously, with the paragraph mark).
Can I APPEND some text after the PARAGRAPH MARK?
(context for advanced users: I want to add a closing tag in xml files)
I will illustrate this:
Example of a paragraphs:
(note that these are actually xml tags you will see)
<name>blablablalblabla, text ended by a PARAGRAPH MARK
<contact>blablablabla, text ended by a PARAGRAPH MARK
Remember: I want to add the closing tags.
I want to search for:
<name>, then some arbitrary text (characters as well as numbers, even punctuation etc...) and then the PARAGRAPH MARK
THEN,
I want to append </name> after the PARAGRAPH MARK.
The same goes for <contact>:
append </contact> after the PARAGRAPH MARK.
How do I setup such a SEARCH AND APPEND? My problem is twofold:
1. How do I express the paragraph mark: is this a carriage return, a line feed, a new line?
2. I know that a . stands for one arbitrary character. How do I formulate multiple arbitrary characters?
I am sure this can be done, but I'm losing my hair because I'm keep pulling them out! I can't figure this out.

Can somebody give some advice. It would be really appreciated!

Levil