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:
- Find the line that starts with “class[space]”
- 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) - add tab before every line in file
- insert “Package[space][myVar]{” at beginning of file
- insert “}” at the very end of file
- 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