Hi List,
I'm playing around with templates for Actionscript, at the moment all's working fine except the class path of the new class I'm generating.
I'm using the TM_DIRECTORY variable in combination with the TM_NEW_FILE_BASENAME as in the original AS template and attempting to parse it with a regexp to change it from a file path the the class path.
i.e. change _workingcopy/com/native/project/package/ClassName to com.native.project.package.ClassName
My limited grasp of regexp is tripping me up however.
As I understand the problem, I need to look for "com" as the start of the class path, strip out anything before that and then convert subsequent slashes to full stops. So far I've got as far as
(.+)(com)(.\w+)\3*
Which as I understand it, matches "com" and then "/[somefoldername]", and then repeats the 3rd match pattern ("/[somefoldername]") until the end of the path on each path segment.
Am I close? How do I now go about replacing each / with a . in the path?
Thanks for any help!
Sam
On 3. Nov 2006, at 13:15, Sam Thorne wrote:
[...] My limited grasp of regexp is tripping me up however.
What command are you using for this? sed?
As I understand the problem, I need to look for "com" as the start of the class path, strip out anything before that and then convert subsequent slashes to full stops. So far I've got as far as
(.+)(com)(.\w+)\3*
Which as I understand it, matches "com" and then "/ [somefoldername]", and then repeats the 3rd match pattern ("/ [somefoldername]") until the end of the path on each path segment.
\3 is a literal match for what the third group captured. In your case, you probably just want:
.*?(com)(/.*)
That will put everything after com (which starts with a slash) into capture #2.
Am I close? How do I now go about replacing each / with a . in the path?
You’d need a second regexp replace for that.