Hoping I might be able to get some help on a regular expression
search/replace method that I need to write to modify a bunch of files.
I've got the pseudocode, but need help with syntax. Here's an example
showing the pattern:
Changing this
···
-------------------
Class my.foo.bar {
}
-------------------
to this
-------------------
Package my.foo{
Class bar {
}
}
-------------------
Here is the pseudo code I came up with
For each file:
1) Find the line that starts with "class[space]"
2) from that file, strip out everything after [space] to the last
period on that line, store in myVar without the final period (in this
case: my.foo)
3) add tab before every line in file
4) insert "Package[space][myVar]{" at beginning of file
5) insert "}" at the very end of file
6) save file and close
It's my first crack at Ruby, so even if no one can provide me with
actual code, any insight would really help.
Thanks in advance!
-wakereh
--
Posted via http://www.ruby-forum.com/.