[Clip] Dot matches newline ON or OFF (was Re: Non printing characters.)
I'm no regex expert, and don't claim to be, but I cannot use this:
> ^!Replace "<span[^>]*>(.*?)</span>" >> "<i>$1</i>" RWithout modifying the spanned aspect every time. The spans I "fix" are each completely different (to each document, not unique, all of them, to each other). In word processing environments, each individual user (every single person) could name that span something completely different, use a different font, and have a different fallback font. Thusly, this span (which as been the subject of this discussion):
<span style='font-family:"Times New Roman Italic","serif"'>
Is unique ONLY to this particular document. Next time, it might be:
It's never the same information inside the span. In fact, because of the cruft that all the word-processing programs out there put out, I can have to make 3, 4 5 or more passes, because a) the spacing between elements or the text inside the span will be different; b) the name of the span will be different, or c) any number of other things will be different, all simply to do nothing more than simply *italicize text.* And this is in a single document.
And I cannot simply regex *all* the spans, because some goodly number of the spans--at least half--are legit, and shouldn't be removed or altered. Believe me, if the spans weren't different each and every time, OF COURSE I would create a clip that I could deploy with a click. I do have "actual" clips like that; those that replace curly quotes with straight, Fix apostrophes, etc. But that only works when the material searched for is always the same. In this case, not only is it not "always" the same, it is NEVER the same, and I don't have the luxury of nuking the precisely 3,937 instances of spans in the HTML document when only some 2-300 of them need to be changed.
And for the other posters: Yes, I've escaped the special characters. Here's a sample paragraph from the copyrighted text I've been working with:
<p class=BodyA style='margin-bottom:3.0pt;text-align:justify;text-indent:.25in'><span
style='font-family:"Times New Roman","serif"'>Emory told them about her long
day -- four photo shoots in three different locations, and one cranky baby who
threw up on her. She found time to squeeze in an occasional text with Mason,
who was bothered by the tone of the Seahawks meeting -- he didn't like to be
doubted and hated having his divorce thrown in his face. Wesley said that was
good news -- it was unlikely Mason would end up there -- but Emory couldn't
help thinking it was still a possibility. </span><span style='font-family:
"Times New Roman Italic","serif"'>How would that work? </span><span
style='font-family:"Times New Roman","serif"'> </span></p>
The ONE span with the <span style='font-family:"Times New Roman Italic","serif"'> throughout the document, which occurs some several hundred times, is what I'm trying to change to, very simply, this:
<i>How would that work? </i>
But the clip that I have previously pasted here several times, which has previously worked without a hiccup, now does not. I have added the previously discussed bit, to resolve the non-printing characters, and, again, this is the "saved un-clip" that I've been using for two years sans issues, but now seems to have gone utterly wonky for no apparent reason (please infer that the "search" etc, are NOT part of the actual "clip," thank you); only what you see between opening and closing brackets is actually part of what goes in the regex search and replace boxes.
Search: <italic span>(.*?)</span> Replace: <i>$1</i>
Thank you. Again.
--- In firstname.lastname@example.org, Axel Berger <Axel-Berger@...> wrote:
> hitch@... wrote:
> > I did not realize that what I'd pasted would be unclear to anyone
> > here. To be clear, in the "search for" field, I used:
> That's what I assumed. Please accept that using the dialogue is NOT a
> > When I say that this is a 'clip,' I keep it stored in my clips
> That one I don't quite get. You use the clipbook to store stuff which
> you then copy and paste into a dialogue? If you were to write
> ^!Replace "<span[^>]*>(.*?)</span>" >> "<i>$1</i>" R
> You could just click on that and be done.
> > Now, I know that I've got "regex" selected, because it's finding
> > the FIND. If regex were not selected, it would not be.
> Yes, agree.
> > Does anyone have any thoughts? Thank you.
> I have to think about that one.
- hitch@... wrote:
> And I cannot simply regex *all* the spans, because some goodlyAre those the same? What I tend to do in cases like that is to first
> number of the spans--at least half--are legit, and shouldn't be
> removed or altered.
mask the things I want to keep, by e.g. renaming to <xspan, alter
everything else, and rename my kept ones back.
> Believe me, if the spans weren't different each and every time,I do believe you. But as stated I have replayed what you described as
> OF COURSE I would create a clip that I could deploy with a click.
exactly as I could and for me it worked flawlessly. Until I can
reproduce your problem I can't begin to think of a workaround. As John
said, give us a) a sample text, b) a find string, and c) a replace
string that don't work and thus reproduce your problem and we can begin
to concoct a solution.
Until that time all I can say is, it works as it should, I don't see
what your problem is. That is not doubting you that there is one, it's
just being incapable of reproducing it.
- At 4/19/2013 05:18 PM, Hitch wrote:
>With the named span inserted where the "italic span" text is now. When I say that this is a 'clip,' I keep it stored in my clips, but as it's never the same (the name and other material for the span can be ANYTHING that somebody in their brain thought up, any name for the span, any font, etc.), it's not viable as a regular "clip." I mean, I could automate it, to the pasting, but...why?"Why" is because (from what you have told us), it is a perfect application for a clip using
>So, I copy-and-paste the name of the span, e.g.:
><span style='font-family:"Times New Roman Italic","serif"'>(.*?)</span>
>then select regex, and then, in the replace box, I've simply always put:
RegEx. ".*" is exactly what "ANYTHING that somebody in their brain thought up" matches.
^!Replace "(?s)<span\s[^>]*?>(.*?)</span>" >> "<i>$1</i>" IHRS
When you see a $n (n=digit), in the result it means the referenced capture substring is undefined. Note: a null string is still defined.
Now this is very strange!! The find works fine but the replace is going bananas.
The result of that command on your test line is:
The parenthesis meta characters are being treated as ordinary characters.
Stranger still (added alternate pattern and set min capture to 1):
^!Replace "(?s)<span\s[^>]*?>(.+?|ZZZ)</span>" >> "<i>$1</i>" IHRS
Applied to (added "Z" between ">" and "("):
<span style='font-family:"Times New Roman Italic","serif"'>Z(.*?)</span>
Still results in:
OK, full debug mode (grouped tags & escaped ">"), group debug output.
Command (long line ahead followed by parenthesis verification):
^!Replace "(?s)(<span\s[^>]*?\>)(.+?|ZZZ)(</span>)" >> "\r\n\$0='$0'\r\n\$1='$1'\r\n\$2='$2'\r\n\$3='$3'\r\n" IRST
( )( )( | )( )
<span style='font-family:"Times New Roman Italic","serif"'>Z(.*?)</span>
$0='<span style='font-family:"Times New Roman Italic","serif"'>Z(.*?)</span>'
$1='<span style='font-family:"Times New Roman Italic","serif"'>'
WIH is going on??? Same behavior with both NTS v5.8/fv & v6.2/fv.
Why is the (.*?) pattern not being treated as a group yet the other ones are?
This should have been a quick reply with a simple command the gremlins have attacked again.