Explanation : Start at the beginning of the string with c or C, followed by :, followed by three times [character \, followed by one or more word characters], followed by a dot, followed by exe at the end of the string.
tnoonan, Yes, but ^ is also used to negate a match when it is used in []
didorno, the truth is, there are other lines within the file that are not absolute path names. What I'm trying to say is that, those *other* lines could be anything. What I intend to match is basically *anything* other than the path of "C:\folder1\folder2\folder3\". Your match would definitely match the first 3 lines, but it won't match the rest of the lines (not shown) because they don't fall into that pattern.
I should applogize for my inconcised explaination. Again, what I want to match is everything except those that have "folder3" under "C:\folder1\folder2\". There could be "C:\folder1\folder2\folder4\file1.exe" in the text file and I wish to match everything except those found in a sub directory under "C:\folder1\folder2\".
tnoonan: Me and Snipah dissed you ? We are on our own ?
What are you talking about ? I didn't see Snipah's post regarding my question and the line you "quoted" was from another post. What did it has anything to do with my question ?
Did I offend you ? If so, I applogize. I have no idea what you talking about just now.
token, the only way to define exactly what you want, is by means of the meta language string itself you are just looking for. I think in principle it is a kind of a paradox. (The hole in the bucket song ?)
didorno, thanks for the reply. Well, my original ideas was pretty simple (at least it seems to me at the time).
For example, assuming I *only* want to match those files that reside in a sub-directory in "c:\folder1\folder2", I would use "c:\\folder1\\folder2\\\w+\\" and that worked.
Now, if I want to negate the last part where I only want to match those files that does NOT reside in a sub-directory in "c:\folder1\folder2", I would use "c:\\folder1\\folder2\\\w+[^\\]", because the "/" is what determines whether there is another sub directory or not. Apprently, that doesn't work as I expected.
means a match for "c:\folder1\folder2\" followed by one or more word characters (including underscore), followed by ONE character which is not \.
So, in your 6 example paths the matches are from c up to and including "folder3", "folder3", "folder3", "file1.", "file2." and "file3." I.E. in the 1st 3 paths the matches stop before the last \, which is according to your pattern, but in the last 3 paths the matches stop after the dots, because \w+ matches file1, file2, file3 and [^\\] matches the dots, also in accordance with your pattern.
If you force the pattern to match till the end of the strings, then you get your desired matches easily. This works
and gives you even the whole desired strings by using the execute method.
Exactly. "c:\\folder1\\folder2\\\w+[^\\]" didn't match because for some @#$% reason, [^\\] will ALWAYS matches the character immediate before the backslash. As a result, the [^\\" will NEVER be "true" :( I wonder why that happens. =(
I was trying to avoid matching the string until the end because according to my "mind", "c:\\folder1\\folder2\\\w+[^\\]" *should* be all I needed; apprently not though. I guess the only way to get it right is to match the entire string until the very end of the string, like what you suggested. As a matter fact, "=[0-9]+$" is what is required, I just didn't mention that because it is not part of the problem and can be solved easily. =)
Anyhow, again, I think the problem have to be solved by matching the entire string like you suggested. I guess I just need to hear this from someone else that this is the only solution. =) and I guess that's just the way regular expression works :\ I wonder who came up with the idea about regexp.
Thanks for all your help and suggestions, greately appreciated.
Exactly. "c:\\folder1\\folder2\\\w+[^\\]" didn't match because for some @#$% reason, [^\\] will ALWAYS matches the character immediate before the backslash.
Token, no, it does what has to be done, the pattern requires at the end one or more word characters, followed by one non \, so this is what you get, it works correct, it has to stop before the \, because that is the non\ character.
A still less strict pattern which you can use is
after the third \ it requires one or more non\ till the end.
c:\\folder1\\folder2\\\w+[^\\] returned 12 lines. c:\\folder1\\folder2\\[^\\]+ returned 12 lines. c:\\folder1\\folder2\\[^\\]+$ returned the desired 3 lines c:\\folder1\\folder2\\\w+[^\\]\w+ returned all 12 lines c:\\folder1\\folder2\\\w+[^\\]\w+$ returned the desired 3 lines
What I was saying was that without the $, it will not work correctly.