..so that i could use it in Notepadd++'s find/replace feature..however i wasnt able to state this part for example..
[A-Z,0-9]{7}
that is to say i didnt know how to say that the 7 chars must be A-Z OR 1-9..i could state each one but thats too long..also i could try using + *..but these are open ended..i couldnt find a way to state a max or a min for the length of chars..
i hope i am making sense :)
Thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I just tested a couple regex expressions and NP++ seems to have support for:
[] expressions, * and +, backreferencing, and ?: to prevent capturing
but doesn't seem to support
| for or expressions and ? for optional parts
For anything else, just try it and see if it works.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
> For anything else, just try it and see if it works.
Yes, that's the way to go... This will help a lot.
Perhaps anyone of you who just tested regular expressions in Notepad++ could write an additional secton for the Wiki? I'm not sure if somewhere is mentioned which regex implementation is used in N++.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I hadn't heard of a shorthand way to express the number of repeats of a marked group or of a single char within a regex. Is there supposed to be a way to do it? I always write out what I need (copy and paste repeatedly as nec).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I searched for this thread, but the search result only returns individual messages. I couldn't grasp the thread number and had to manually go back in the forum's history to pick the thread's link. Luckily, its last message wasn't posted that long ago. Does anyone know how to quickly get to the thread of a search result's individual message?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I don't know if you have found this out or not, but there shouldn't be a comma in between the []. It should read [A-Z0-9]. Anything in between [] are allowable characters except for special characters that mean something like -, putting a comma in there means that it will search for a comma along with the rest of the characters. So for [0,1,5,6] it would be just [0156].
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry, I noticed some other things wrong with your regex. One of them is [0]. I am guessing you want a 0 to match here but it doesn't have to be in []. [] are a way of saying match any one character that appears in this list. So what you are saying is match any one character that is a 0, which can be done by just putting a 0 there. Oh and the + and * mean 1 or more and 0 or more, respectively. So for example [abc]+ would match a, aa, ab, bacab, etc. as it will continue as long as there is either an a, b, or c as the next character. So for your regex, I would change:
[A-Z,0-9]{7}[0-9][0,1,5,6][0-9]([0][1-9]|[1-5][0-9]|[3][0,1])[0-9][A-Z,0-9]{3}[A-Z]{3}
to
[A-Z0-9]{7}[0-9][0156][0-9]((0[1-9])|([1-5][0-9])|(3[01]))[0-9][A-Z0-9]{3}[A-Z]{3}
I have added extra () around certain expressions to help out the or token |. I am not sure if you mean 0[1-9] or [1-5][0-9] or if you meant 0([1-9] or [1-5][0-9]) but I am assuming if was the first one so the parenthesis should help that out. If you use back-referencing, however, and don't want these extra parenthesis to be captured, use ?: as the first part inside the parentheses. So your regex would then be:
[A-Z0-9]{7}[0-9][0156][0-9]((?:0[1-9])|(?:[1-5][0-9])|(?:3[01]))[0-9][A-Z0-9]{3}[A-Z]{3}
Now I am not a regex expert so if anything of this is wrong, I am sorry, however I do strongly believe this is all proper and legal regex. If NP++ doesn't recognize this then I would say there is a bug in it, or it doesn't support all of regex's features.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
All nice but did anyone check if the pipe | does work in Notepad++, similar as someone dropping a link here to some general regex documentation, which may not at all apply to Notepad++. I think this is not very much helping in solving the real problem here.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I also want to include that it has support for:
\d for digits, \D for non-digits, \w for words, \W for non-words, \s for space, and \S for non-space and probably others.
but unfortunately doesn't support:
{number} for specifying a certain amount such as [A-Z]{3} meaning find exactly 3 contiguous characters that are in the range of A-Z. So, yeah, as one of the previous posts mentioned, you will have to write our [A-Z][A-Z][A-Z]. But there is another use for a number in {}. If you want to specify a range from a low number to a high number of matches. So for example, [A-Z]{3,5} will match 3, 4, or 5 contiguous characters in the range of A-Z. Since NP++ doesn't support ? for optional characters nor |, I don't see a simple way of expressing this. So this should definitely be looked into and support should be added.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, firstly i have to say this, NOTEPAD++ ROCKS! thanks a lot to everyone on its project
Now, I am having a small amount of trouble with the regular expression used in Notepad++
basically i wanted to convert this expression..
[A-Z,0-9]{7}[0-9][0,1,5,6][0-9]([0][1-9]|[1-5][0-9]|[3][0,1])[0-9][A-Z,0-9]{3}[A-Z]{3}
..so that i could use it in Notepadd++'s find/replace feature..however i wasnt able to state this part for example..
[A-Z,0-9]{7}
that is to say i didnt know how to say that the 7 chars must be A-Z OR 1-9..i could state each one but thats too long..also i could try using + *..but these are open ended..i couldnt find a way to state a max or a min for the length of chars..
i hope i am making sense :)
Thanks
I just tested a couple regex expressions and NP++ seems to have support for:
[] expressions, * and +, backreferencing, and ?: to prevent capturing
but doesn't seem to support
| for or expressions and ? for optional parts
For anything else, just try it and see if it works.
> For anything else, just try it and see if it works.
Yes, that's the way to go... This will help a lot.
Perhaps anyone of you who just tested regular expressions in Notepad++ could write an additional secton for the Wiki? I'm not sure if somewhere is mentioned which regex implementation is used in N++.
I hadn't heard of a shorthand way to express the number of repeats of a marked group or of a single char within a regex. Is there supposed to be a way to do it? I always write out what I need (copy and paste repeatedly as nec).
I don't think {7} is supported, so you'll just have to write it all out. See http://notepad-plus.sourceforge.net/uk/regExpList.php for what's supported. If you use regex a lot, you might also want to read http://notepad-plus.wiki.sourceforge.net/FindReplaceNewlineHowTo for future reference.
Also notice the limitation on the length of the regular expression in the thread below:
http://sourceforge.net/forum/forum.php?thread_id=1877767&forum_id=331754
(Help forum)
I searched for this thread, but the search result only returns individual messages. I couldn't grasp the thread number and had to manually go back in the forum's history to pick the thread's link. Luckily, its last message wasn't posted that long ago. Does anyone know how to quickly get to the thread of a search result's individual message?
You might replace [A-Z,0-9] by \w, which will also match lower case characters.
http://www.regular-expressions.info/reference.html
Is this the correct and a complete reference?
I don't know if you have found this out or not, but there shouldn't be a comma in between the []. It should read [A-Z0-9]. Anything in between [] are allowable characters except for special characters that mean something like -, putting a comma in there means that it will search for a comma along with the rest of the characters. So for [0,1,5,6] it would be just [0156].
Sorry, I noticed some other things wrong with your regex. One of them is [0]. I am guessing you want a 0 to match here but it doesn't have to be in []. [] are a way of saying match any one character that appears in this list. So what you are saying is match any one character that is a 0, which can be done by just putting a 0 there. Oh and the + and * mean 1 or more and 0 or more, respectively. So for example [abc]+ would match a, aa, ab, bacab, etc. as it will continue as long as there is either an a, b, or c as the next character. So for your regex, I would change:
[A-Z,0-9]{7}[0-9][0,1,5,6][0-9]([0][1-9]|[1-5][0-9]|[3][0,1])[0-9][A-Z,0-9]{3}[A-Z]{3}
to
[A-Z0-9]{7}[0-9][0156][0-9]((0[1-9])|([1-5][0-9])|(3[01]))[0-9][A-Z0-9]{3}[A-Z]{3}
I have added extra () around certain expressions to help out the or token |. I am not sure if you mean 0[1-9] or [1-5][0-9] or if you meant 0([1-9] or [1-5][0-9]) but I am assuming if was the first one so the parenthesis should help that out. If you use back-referencing, however, and don't want these extra parenthesis to be captured, use ?: as the first part inside the parentheses. So your regex would then be:
[A-Z0-9]{7}[0-9][0156][0-9]((?:0[1-9])|(?:[1-5][0-9])|(?:3[01]))[0-9][A-Z0-9]{3}[A-Z]{3}
Now I am not a regex expert so if anything of this is wrong, I am sorry, however I do strongly believe this is all proper and legal regex. If NP++ doesn't recognize this then I would say there is a bug in it, or it doesn't support all of regex's features.
All nice but did anyone check if the pipe | does work in Notepad++, similar as someone dropping a link here to some general regex documentation, which may not at all apply to Notepad++. I think this is not very much helping in solving the real problem here.
I also want to include that it has support for:
\d for digits, \D for non-digits, \w for words, \W for non-words, \s for space, and \S for non-space and probably others.
but unfortunately doesn't support:
{number} for specifying a certain amount such as [A-Z]{3} meaning find exactly 3 contiguous characters that are in the range of A-Z. So, yeah, as one of the previous posts mentioned, you will have to write our [A-Z][A-Z][A-Z]. But there is another use for a number in {}. If you want to specify a range from a low number to a high number of matches. So for example, [A-Z]{3,5} will match 3, 4, or 5 contiguous characters in the range of A-Z. Since NP++ doesn't support ? for optional characters nor |, I don't see a simple way of expressing this. So this should definitely be looked into and support should be added.