regex - HTML Escaping - Reg expressions? -
I would like to escape a specific phrase automatically and logically, which is currently accompanied by highlights words with quotation marks There is a statement. Within the statement, quotations or inches marks can also be used to describe the distance.
The phrase can be:
Paul said "it missed us about a leg" In fact, it was only about 9 ".
To avoid this phrase, it must actually be
Paul said & amp; ldquo; about a foot; & quot; actually it only gives 9 & prime ;. .
Paul said, "It missed us about a foot." In fact it is only 9 ". I can not think of adding a sample phrase to "It may be too, but it can be!
I have characters with runtime I am looking for some help on identifying which of the escape values to change. The phrase was only an example and it can be anything but should be formed properly, that is, if we read correctly Avoid an opening and closing quotation Will be.
Do I want to use a regular expression to find a quoted phrase in the text? "" Change the first letter of a full stop and then the first for the first time.
& ldquo; then
& amp; rdquo; if I have found someone, then replace it with & quot;
until it happens after the number where i
and principal; How many quotes can I get within a sentence? How will I deal with this?
"It just missed" Paul said "with the foot."
It actually drinks me .....
& Lt; Pre & gt; "It just missed" Paul said "about 9". & Lt; / Pre & gt; You should read the above correctly after surviving. (I'm showing real time this time)
"It just missed" Paul said "9" almost ".
Obviously this is a case of an edge but I wonder. It is possible to avoid this on runtime without understanding the content? If more help is not given on clear phrases, then it will be appreciated.
I will do it in two passes:
The first pass for any of the S is immediately before the number and And he substitutes:
s / ([0-9]) "/ \ 1 and principal; / G
Depending on the text you are working with, you may need to extend this rijks; I've checked for points only for simplicity.
By keeping them in mind, a second pass may be changed as a pair again as you have described:
s / "([^" ] *) Use the note "/ & ldquo; \ 1 & amp; rdquo; / g
[^"] * instead of . * - We want to find two numbers of two quotes with non-double quotes characters in any number between them. Restrictions, there will be no problem in handling stars with multiple quoted classes. (It can also be accomplished using non-greedy . *? , but a negative character class is more clearly your intent and, in most regex implementation, is more efficient.)
A disorientation, mismatched "somewhere in the string, or an inch marker that is remembered from the first pass, still can cause problems, of course, but nobody is applying the understanding of the material The way to avoid that possibility without doing it.
Comments
Post a Comment