Topic: Regular expression
I am parsing files, but I only want to parse them if they are in a certain format. This is what they are supposed to look like:
It starts with a letter, any letter, then can be any amount of any numbers 0-9. Then an underscore. Then any amount of any characters a-z until a dash. Then any amount of characters a-z until an underscore. Then any amount of any characters until the next underscore. Then any amount of characters a-z until another underscore, and so on until it's finished.
This is what I have so far the 'i' after the code makes it case insensitive:
It's not finished because I'm stuck with the underscore right after the long number separated by periods. It matches perfectly until the underscore after that number but instead of stopping at the underscore after the number before 'led', it continues on until the next underscore and stops there?
The red code should have every character after the '-sp_' and up until the next underscore (blue underscore), but instead it captures everything up until the underscore after 'led' (red underscore). I'm not sure why it won't stop at the first underscore in it's path, but it doesn't, it stops at the second one. Why is this? I want it to stop at the first underscore. How can I change this?
Sorry that's probably confusing, maybe the best way to see what I mean is to do this:
go to this regexp editor and copy and paste this reg exp:
and copy and paste the string to match:
I hope you can understand that. Thanks in advance.
Last edited by RailsRhino (2010-07-20 16:18:20)