Proper Case In XML

Help with writing and playing macros

Proper Case In XML

Postby BaxterB » Tue Jan 20, 2009 3:13 am

Howdy all!

First, I want to let everyone know that I did search the forum, and I did try everything that looked even remotely close to what I was looking for. The problem, I'm afraid, is that it's just not making much sense to me. It could be the late hour, or it could be that I'm just mentally challenged. At this point I'm not going to rule either out.

What I need to do is this: I have nearly 10,000 lines of XML code and I need to change a snippet in each to proper case. Each line contains the following syntax:

<![CDATA[This is some sample text]]></phrase>

How can I find and select that part from each line? So that I can change the text between <![CDATA[ and ]]></phrase> to proper case, like this:

<![CDATA[This Is Some Sample Text]]></phrase>

I really do appreciate any help I can get in figuring this out.
BaxterB
Newbie
 
Posts: 1
Joined: Mon Jan 19, 2009 10:34 pm

Re: Proper Case In XML

Postby pietzcker » Tue Jan 20, 2009 3:38 am

I'm no macro expert, but this works on my PC (using UE 14.20.1.1006):

Code: Select all
InsertMode
ColumnModeOff
HexOff
Top
PerlReOn
Loop 0
Find RegExp "(?<=<!\[CDATA\[)[^]]+(?=\]\]></phrase>)"
IfNotFound
ExitLoop
Else
ToCaps
EndIf
EndLoop

The macro property "Continue if a Find with Replace not found" or "Continue if search string not found" should be checked.

The regex looks for any block of text that doesn't contain a "]" character and that is situated between the two delimiters you specified. It then applies the command "ToCaps" to it until it can't find any more occurences of the text.

If you need to be able to handle escaped brackets like <![CDATA[This is some \[sample\] text]]></phrase>, that could also be worked into the regex - let me know if that's necessary.

Cheers,
Tim
User avatar
pietzcker
Master
Master
 
Posts: 241
Joined: Sun Aug 22, 2004 11:00 pm


Return to Macros