looking for a regex that allows just parts of an ip.
Moderator: General Moderators
- prometheuzz
- Forum Regular
- Posts: 779
- Joined: Fri Apr 04, 2008 5:51 am
Re: looking for a regex that allows just parts of an ip.
hi,
i hope its not cheeky to ask one more time for a solution...
the needs has been changed and the mac can be entered now in 4 formats.
00:22:64:07:BB:4A
00-22-64-07-BB-4A
00226407BB4A
0022.6407.BB4A
and also for all this formats it should be possible to enter only a part of the mac...
H6-G9 for example
has anyone a RegEx that matches that needs???
thank u a lot!
i hope its not cheeky to ask one more time for a solution...
the needs has been changed and the mac can be entered now in 4 formats.
00:22:64:07:BB:4A
00-22-64-07-BB-4A
00226407BB4A
0022.6407.BB4A
and also for all this formats it should be possible to enter only a part of the mac...
H6-G9 for example
has anyone a RegEx that matches that needs???
thank u a lot!
- prometheuzz
- Forum Regular
- Posts: 779
- Joined: Fri Apr 04, 2008 5:51 am
Re: looking for a regex that allows just parts of an ip.
Note that a public forum is meant to educate people about something they like to learn more about.s0h0 wrote:hi,
i hope its not cheeky to ask one more time for a solution...
the needs has been changed and the mac can be entered now in 4 formats.
00:22:64:07:BB:4A
00-22-64-07-BB-4A
00226407BB4A
0022.6407.BB4A
and also for all this formats it should be possible to enter only a part of the mac...
H6-G9 for example
has anyone a RegEx that matches that needs???
thank u a lot!
Without posting the things you have tried yourself, it looks* like you're just outsourcing your work here for free. I like to help people, but I find it less entertaining if people see me as an easy (and cheap!) way to do their work.
So, if you have a specific question abut some regex you wrote (but didn't work), feel free to ask it here, otherwise, I'm not interested in helping. I've already given you quite a bit of examples to work with after all.
Good luck.
* With an emphasis on the word "looks": I'm not saying you didn't try, nut by not posting your attempt, I don't know what the case is.
Re: looking for a regex that allows just parts of an ip.
hi,
yes u are right! i just asked that cause i dont have a clou how i should get on that problem.
sorry, i wouldnt make u doing my work...
yes u are right! i just asked that cause i dont have a clou how i should get on that problem.
sorry, i wouldnt make u doing my work...
Re: looking for a regex that allows just parts of an ip.
^([0-9a-zA-Z]{2}[:-]){0,5}[0-9a-zA-Z]{1,2}$
i got it to make the RegEx to allow just parts of the mac. but how i can hang on "or with 4 values and a dot as delimiter" i dont know...
i thought on something like this... but i know || wont work as OR assignment...
^([0-9a-zA-Z]{2}[:-]){0,5}[0-9a-zA-Z]{1,2}$ || ^([0-9a-zA-Z]{4}[.]){0,3}[0-9a-zA-Z]{1,4}$ || ^([0-9a-zA-Z]{1,12}
i got it to make the RegEx to allow just parts of the mac. but how i can hang on "or with 4 values and a dot as delimiter" i dont know...
i thought on something like this... but i know || wont work as OR assignment...
^([0-9a-zA-Z]{2}[:-]){0,5}[0-9a-zA-Z]{1,2}$ || ^([0-9a-zA-Z]{4}[.]){0,3}[0-9a-zA-Z]{1,4}$ || ^([0-9a-zA-Z]{1,12}
Re: looking for a regex that allows just parts of an ip.
I have no idea what you're trying to do but you can use | (single bar) for an OR in regex.

Re: looking for a regex that allows just parts of an ip.
lol, Thank u!
^([0-9a-zA-Z]{2}[:-]){0,5}[0-9a-zA-Z]{1,2}$|^([0-9a-zA-Z]{4}[.]){0,2}[0-9a-zA-Z]{1,4}$
this one works for 3 of the 4 formats i need! im just a step away from a solution!
^([0-9a-zA-Z]{2}[:-]){0,5}[0-9a-zA-Z]{1,2}$|^([0-9a-zA-Z]{4}[.]){0,2}[0-9a-zA-Z]{1,4}$
this one works for 3 of the 4 formats i need! im just a step away from a solution!
- prometheuzz
- Forum Regular
- Posts: 779
- Joined: Fri Apr 04, 2008 5:51 am
Re: looking for a regex that allows just parts of an ip.
And it will also match these strings:s0h0 wrote:lol, Thank u!
^([0-9a-zA-Z]{2}[:-]){0,5}[0-9a-zA-Z]{1,2}$|^([0-9a-zA-Z]{4}[.]){0,2}[0-9a-zA-Z]{1,4}$
this one works for 3 of the 4 formats i need! im just a step away from a solution!
Code: Select all
00:22
00:22-00:22-0
00-0
0022.6407.B
B
0000.A- prometheuzz
- Forum Regular
- Posts: 779
- Joined: Fri Apr 04, 2008 5:51 am
Re: looking for a regex that allows just parts of an ip.
Hint: first create 4 different regex-es that match each of these four different cases (nothing more than that!). When you have that working, only then combine them into one regex.s0h0 wrote:hi,
i hope its not cheeky to ask one more time for a solution...
the needs has been changed and the mac can be entered now in 4 formats.
00:22:64:07:BB:4A
00-22-64-07-BB-4A
00226407BB4A
0022.6407.BB4A
...
Good luck.
Re: looking for a regex that allows just parts of an ip.
thank u for ur help again.
but isnt that what i needed? it allows all 4 formats and just parts of it...?
but isnt that what i needed? it allows all 4 formats and just parts of it...?
- prometheuzz
- Forum Regular
- Posts: 779
- Joined: Fri Apr 04, 2008 5:51 am
Re: looking for a regex that allows just parts of an ip.
That is for yourself to answer. If your regex accpets these (invalid!) addresses as well:s0h0 wrote:thank u for ur help again.
but isnt that what i needed? it allows all 4 formats and just parts of it...?
Code: Select all
00:22
00:22-00:22-0
00-0
0022.6407.B
B
0000.A
// etc.I mean, you mind as well use the regex:
Code: Select all
^.*$Re: looking for a regex that allows just parts of an ip.
lol^.*$
the mac should be used for a search on a database... so also parts of macs should be allowed. but they must be entered in an valid format.
which entrys would u allow if u need those 4 formats and just parts of them?
maybe that should not be allowed... 00:22-00:22-0
on server side all character like -,:,. will be removed and after every second character an minus will be inserted.
- prometheuzz
- Forum Regular
- Posts: 779
- Joined: Fri Apr 04, 2008 5:51 am
Re: looking for a regex that allows just parts of an ip.
Why validate at all? Why not just query the database?s0h0 wrote:...
the mac should be used for a search on a database...
Ah, a new requirement... Up until now you've only mentioned "whole" mac addresses, not parts of them. And then the question is what parts of addresses do you want to accept as valid and which ones as invalid?s0h0 wrote:so also parts of macs should be allowed.
Would the string "cafe" would also be valid since it's a valid hexadecimal literal? And what about "F"?
Again: that is for you to decide.s0h0 wrote:...
which entrys would u allow if u need those 4 formats and just parts of them?
maybe that should not be allowed... 00:22-00:22-0
...
Re: looking for a regex that allows just parts of an ip.
yes u are right again, i will resolve the specification first...
Re: looking for a regex that allows just parts of an ip.
ok, my boss said that entries are to be allowed... so it looks like i reached the target.
thank u for this time
i got a lil bit closer to regex and now it dont looks like hieroglyphs only 
thank u for this time
Last edited by s0h0 on Wed Mar 04, 2009 8:32 am, edited 1 time in total.