IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Help! How to programatically edit case of strings?
We have a file full of shtuff like <someTag><attr ibute="bl-ah">MY_STRING_VALUE</attr>, which we'd like to become more like <someTag><attr ibute="bl-ah">My_String_Value</attr>.

I suspect this should be possible to do with sed or awk or something -- which seem to be available on the client's proprietary Unix platform -- but I sure can't seem to come up with the correct incantations to do it on my own. :-(

One could easily change the <someTag><attr ibute="bl-ah"> and </attr> bits to something else temporarily (global search-and-replace in a text editor), if the <s, /s, and >s are a hindrance (and then change them back afterwards).

That would simplify(?) the problem to something like: Change @MY_STRING_VALUE\ufffd to @My_String_Value\ufffd throughout the file... And I don't know how to do that either. :-(

Anyone?


   [link|mailto:MyUserId@MyISP.CountryCode|Christian R. Conrad]
(I live in Finland, and my e-mail in-box is at the Saunalahti company.)
Ah, the Germans: Masters of Convoluted Simplification. — [link|http://www.thetruthaboutcars.com/?p=1603|Jehovah]
New Problem restated
Camel case ALL text not found with angle brackets.

This seems to be what you are saying.

Or is is a matter of when we see a PARTICULAR tag, camel case the following string.

Or something else.

If you don't have Perl on the system, can you get the files on a system that does?
New Particular - SOME tag, not any other tag.
Hmm... Yeah, if I installed Perl on my Windows (XP Pro) PC at work.

Anybody know an MS-Word macro to do the same thing? I already have Word on the box, wouldn't have to install anything.


   [link|mailto:MyUserId@MyISP.CountryCode|Christian R. Conrad]
(I live in Finland, and my e-mail in-box is at the Saunalahti company.)
Ah, the Germans: Masters of Convoluted Simplification. — [link|http://www.thetruthaboutcars.com/?p=1603|Jehovah]
New The ultimate clueless non-programmer wannabe approach
Jesus FFING Christ!

You would ask for a VB macro to handle that type of processing to avoid a 5 minute ActiveState Perl download and install.

pfft!

Write it yourself.

New Thanks a lot... (new thread)
Created as new thread #275547 titled [link|/forums/render/content/show?contentid=275547|Thanks a lot...]


   [link|mailto:MyUserId@MyISP.CountryCode|Christian R. Conrad]
(I live in Finland, and my e-mail in-box is at the Saunalahti company.)
Ah, the Germans: Masters of Convoluted Simplification. — [link|http://www.thetruthaboutcars.com/?p=1603|Jehovah]
New Well, in Squeak it would look something like
\ndoc := XMLDOMParser parseDocumentFrom: (FileDirectory current fileNamed: 'file.xml').\ndoc tagsNamed: 'attr' do:\n[:each |\n    each contentsDo:\n    [:t | t isText ifTrue: [t string: (((t string asLowercase split: '_') collect: [:s | s capitalized]) join: '_') ]]\n].\n(FileDirectory current forceNewFileNamed: 'file.xml') nextPutAll: (doc asString); close.\n


Edit: fixed formatting



[link|http://www.blackbagops.net|Black Bag Operations Log]

[link|http://www.objectiveclips.com|Artificial Intelligence]

[link|http://www.badpage.info/seaside/html|Scrutinizer]
Expand Edited by tuberculosis Dec. 12, 2006, 09:11:11 PM EST
Expand Edited by tuberculosis Dec. 12, 2006, 09:13:09 PM EST
New UltraEdit will do it.
I cut and pasted your example text in my copy of UltraEdit 9.00a:

<someTag><attr ibute="bl-ah">MY_STRING_VALUE</attr>


highlighted it, then did:

Format -> Capitalize

and it changed the text to:

<Sometag><Attr Ibute="Bl-Ah">My_String_Value</Attr>.


Is that close enough? I'm sure with the various searching options, and the ability to record macros, something could be cobbled together relatively quickly that you could save as a macro. It's pretty easy.

[link|http://www.ultraedit.com/index.php?name=Downloads&d_op=viewdownload&cid=1|UltraEdit] is shareware - that link is to the 45 day trial page of UE 12.20a.

There are probably free editors that will do the same thing, and be simpler to set up than a programming enviroment like perl or Python.

HTH a bit.

Cheers,
Scott.
New at risk of a war, do this
[link|http://math.claremontmckenna.edu/ALee/emacs/emacs.html|http://math.claremon.../emacs/emacs.html]
thanx,
bill
Any opinions expressed by me are mine alone, posted from my home computer, on my own time as a free american and do not reflect the opinions of any person or company that I have had professional relations with in the past 51 years. meep

reach me at [link|mailto:bill.oxley@cox.net|mailto:bill.oxley@cox.net]
New alt-C, bay-bee.
Add a keyboard macro in the mix, and you're good to go. ;-)
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New Go ahead
Write the lisp code the parse out particular tags.
And explain it to him.

NOT YOU SCOTT!
New get vi'ed :-) I dont use that shite
Any opinions expressed by me are mine alone, posted from my home computer, on my own time as a free american and do not reflect the opinions of any person or company that I have had professional relations with in the past 51 years. meep

reach me at [link|mailto:bill.oxley@cox.net|mailto:bill.oxley@cox.net]
New Who the fsck writes LISP to use Emacs?
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New Ok, fine.
Please show your solution in emacs.
New I need more of the problem specifics
But it would be something along the lines of this keyboard macro:

^( ^s <name_of_tag ^f ^space ^s </name_of_tag> alt-b alt-b alt-b ^b ^b esc-x capitalize-region ^)

Then run the keyboard macro as many times as you need to. Basically it says, "find the next instance of the tag, mark everything in between the tag and the close tag as the region, then capitalize it".

It's a lot quicker to actually make the macro than it is to type it out, since you just do the editing commands you want to record. Probably 10-20 seconds to make the macro, then however long it takes to process the file.
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New Hope it's a single file
Initial post a "a file full of shtuff" so no need to load and save a bunch.
New As always, use the right tool for the job.
For the majority of my text munging needs, emacs keyboard macros are capable, fast and easy.
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New Bunch of text mungers
its xml - thus a serialized object model.

Easier and more reliable to work on the dom I think.

But go ahead and live in your flat little world.



[link|http://www.blackbagops.net|Black Bag Operations Log]

[link|http://www.objectiveclips.com|Artificial Intelligence]

[link|http://www.badpage.info/seaside/html|Scrutinizer]
New Er, come again?
20 seconds of work to do a one-off, vs. thinking and writing a program to do it the "correct" way. And what's the point of creating an object graph for the entire thing when he wants to change one tag's contents only?

I get work done. I don't worry too much about how I get it done unless it actually matters.

"flat little world"... Man, talk about your insults out of nowhere.
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New thats our todd, no point manipulating some text
when you can write a hello world example only using 11MB's of libraries and manipulating some text.
thanx,
bill
Any opinions expressed by me are mine alone, posted from my home computer, on my own time as a free american and do not reflect the opinions of any person or company that I have had professional relations with in the past 51 years. meep

reach me at [link|mailto:bill.oxley@cox.net|mailto:bill.oxley@cox.net]
New Probably smaller than emacs, though :-P
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New Eh? I did it in 3 lines.
Anyhow, I find it easier to modify data structures than to fiddle text- which is error prone. When the text represents a data structure, like source code or xml, modifying the parse tree is more reliable and, I think, easier.

Anyhow, you're taking me way too seriously. :-)



[link|http://www.blackbagops.net|Black Bag Operations Log]

[link|http://www.objectiveclips.com|Artificial Intelligence]

[link|http://www.badpage.info/seaside/html|Scrutinizer]
Expand Edited by tuberculosis Dec. 12, 2006, 09:15:23 PM EST
New Re: Eh? I did it in 3 lines.
If I were going to do it more than once, sure. Otherwise it's a waste of time. Writing a keyboard macro is simple and quick, much quicker than even your 3 lines of code.
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New emacs is xml?
Any opinions expressed by me are mine alone, posted from my home computer, on my own time as a free american and do not reflect the opinions of any person or company that I have had professional relations with in the past 51 years. meep

reach me at [link|mailto:bill.oxley@cox.net|mailto:bill.oxley@cox.net]
New Re: Ok, fine.
The following macro:

;; Keyboard Macro Editor. Press C-c C-c to finish; press C-x k RET to cancel.
;; Original keys: C-s <attr 2*M-f 2*C-f C-SPC C-s </att 5*C-b ESC xcapital TAB reg TAB RET

Command: last-kbd-macro
Key: none

Macro:

C-s\t\t\t;; isearch-forward
<attr\t\t\t;; self-insert-command * 5
2*M-f\t\t\t;; forward-word
2*C-f\t\t\t;; forward-char
C-SPC\t\t\t;; set-mark-command
C-s\t\t\t;; isearch-forward
</att\t\t\t;; self-insert-command * 5
5*C-b\t\t\t;; backward-char
ESC
xcapital\t\t;; self-insert-command * 4
TAB\t\t\t;; lisp-indent-line
reg\t\t\t;; self-insert-command * 3
TAB\t\t\t;; lisp-indent-line
RET\t\t\t;; newline


Used on the following:

asdsgas<attr ibute="foo">DINGLE_BERRIES</attr>jlj;lj;l
<attr ibute="foo">DINGLE_BERRIES</attr><moo>on you</moo>
<attr ibute="foo">DINGLE_BERRIES</attr><barry>likes herrings</barry>
<attr ibute="foo">DINGLE_BERRIES</attr>

Produces:

asdsgas<attr ibute="foo">Dingle_Berries</attr>
jlj;lj;l<attr ibute="foo">Dingle_Berries</attr><moo>on you</moo>
<attr ibute="foo">Dingle_Berries</attr>
<barry>likes herrings</barry>
<attr ibute="foo">Dingle_Berries</attr>

Like I said, the exact form of the macro is going to depend on the specific data.

The macro above is suitable for pasting into ^x^k^xe, incidentally. ;-)
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New Thanks, Scotts.
Yeah, Neo, I might even have tried vi or emacs, if I hadn't happened to have pretty much the same capabilities installed already (as can be seen in my reply to Barry's charming retort.)

And yeah, CollieKat, from your description the text editor you recommended seems to be pretty much as powerful as the one I use... i.e, *almost* powerful enough to do it! :-)

Thanks anyway, both of ya.

Really.


   [link|mailto:MyUserId@MyISP.CountryCode|Christian R. Conrad]
(I live in Finland, and my e-mail in-box is at the Saunalahti company.)
Ah, the Germans: Masters of Convoluted Simplification. — [link|http://www.thetruthaboutcars.com/?p=1603|Jehovah]
     Help! How to programatically edit case of strings? - (CRConrad) - (24)
         Problem restated - (crazy) - (3)
             Particular - SOME tag, not any other tag. - (CRConrad) - (2)
                 The ultimate clueless non-programmer wannabe approach - (crazy) - (1)
                     Thanks a lot... (new thread) - (CRConrad)
         Well, in Squeak it would look something like - (tuberculosis)
         UltraEdit will do it. - (Another Scott)
         at risk of a war, do this - (boxley) - (16)
             alt-C, bay-bee. - (admin)
             Go ahead - (crazy) - (14)
                 get vi'ed :-) I dont use that shite -NT - (boxley)
                 Who the fsck writes LISP to use Emacs? -NT - (admin) - (12)
                     Ok, fine. - (crazy) - (11)
                         I need more of the problem specifics - (admin) - (9)
                             Hope it's a single file - (crazy) - (8)
                                 As always, use the right tool for the job. - (admin) - (7)
                                     Bunch of text mungers - (tuberculosis) - (6)
                                         Er, come again? - (admin) - (4)
                                             thats our todd, no point manipulating some text - (boxley) - (1)
                                                 Probably smaller than emacs, though :-P -NT - (admin)
                                             Eh? I did it in 3 lines. - (tuberculosis) - (1)
                                                 Re: Eh? I did it in 3 lines. - (admin)
                                         emacs is xml? -NT - (boxley)
                         Re: Ok, fine. - (admin)
         Thanks, Scotts. - (CRConrad)

Can bitching and moaning atone?
219 ms