On 04/28/2009 04:10 PM, AJ ONeal wrote:
> Essentially I have several hundred lines like
> hideField(fieldName())
>
> which I would like to turn into
> $('#field_name').hide()This shouldn't be too bad. With regex, you can take advantage of () to store stuff in RAM to use later on. So, the idea is: (field)(Name) would store 'field' in \1, 'Name' in \2. We can use '\l' to lowercase a stored value. So, "Name" would become "name". Then of course, add the rest of the text. Without testing, here's a quick hack (should be on one line) that won't edit your file, but show you the results on STDOUT. Add the -i switch to operate on the file. sed -r 's/^hideField\([a-z]+)([A-Z][a-z]+)\(\)\)$/\$\(\'\#\1_\l\2'\)\.hide\(\)/g' foo.txt -- . O . O . O . . O O . . . O . . . O . O O O . O . O O . . O O O O . O . . O O O O . O O O
signature.asc
Description: OpenPGP digital signature
-------------------- BYU Unix Users Group http://uug.byu.edu/ The opinions expressed in this message are the responsibility of their author. They are not endorsed by BYU, the BYU CS Department or BYU-UUG. ___________________________________________________________________ List Info (unsubscribe here): http://uug.byu.edu/mailman/listinfo/uug-list
