Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: Bodom - lokakuu 09, 2013, 01:35:56 IP

Otsikko: Regex Input Mask for Steam IDs
Kirjoitti: Bodom - lokakuu 09, 2013, 01:35:56 IP
Hello,

I was wondering how to create an input mask for my custom field of Steam IDs. Steam IDs look like this Steam_0:1:123 but may have more digits (Steam_0:1:1234567). I was wondering how to create an input mask for these to stop people from just typing anything in, and still being able to register.

Thanks for your help,
-Bodom
Otsikko: Re: Regex Input Mask for Steam IDs
Kirjoitti: Arantor - lokakuu 09, 2013, 03:02:25 IP
Seems to me then that you want something like:

/Steam_0:1:\d+/

Assuming 0:1 are constants and the other digits can be anything. If that's not the case more details will be necessary.
Otsikko: Re: Regex Input Mask for Steam IDs
Kirjoitti: Bodom - lokakuu 09, 2013, 03:08:50 IP
Yes the 0 and 1 is constant.
Thank you for your help! I will post back here after some testing, but I'd assume that you know what you're doing and this should work without an issue.

Thanks again,
-Bodom

P.s.
The other digits are only ever numbers, is there a way to add that?
Otsikko: Re: Regex Input Mask for Steam IDs
Kirjoitti: Arantor - lokakuu 09, 2013, 03:30:01 IP
It does that, \d means digits only ;)
Otsikko: Re: Regex Input Mask for Steam IDs
Kirjoitti: Bodom - lokakuu 09, 2013, 07:20:35 IP
Sorry for the delay in my response, but thanks again! :D
Otsikko: Re: Regex Input Mask for Steam IDs
Kirjoitti: Bodom - lokakuu 09, 2013, 07:26:01 IP
Is there a way to make the STEAM entry non-case sensitive?
So you could enter steam, STEAM, Steam or any variation, just as long as its steam then followed by the number.
Otsikko: Re: Regex Input Mask for Steam IDs
Kirjoitti: Arantor - lokakuu 09, 2013, 07:33:49 IP
/Steam_0:1:\d+/i
Otsikko: Re: Regex Input Mask for Steam IDs
Kirjoitti: Bodom - lokakuu 09, 2013, 09:51:52 IP
Thanks again!
Otsikko: Re: Regex Input Mask for Steam IDs
Kirjoitti: Bodom - lokakuu 10, 2013, 12:43:33 AP
Okay so the 1 is not constant xP
I should have checked.. It can be Steam_0:0 or Steam_0:1
Otsikko: Re: Regex Input Mask for Steam IDs
Kirjoitti: Arantor - lokakuu 10, 2013, 10:40:49 AP
/Steam_0:[01]:\d+/i
Otsikko: Re: Regex Input Mask for Steam IDs
Kirjoitti: Bodom - lokakuu 11, 2013, 02:01:05 IP
Sorry, I should have thanked you and marked this as solved.
Thanks for your help, works perfectly!

-Bodom
Otsikko: Re: Regex Input Mask for Steam IDs
Kirjoitti: Arantor - lokakuu 11, 2013, 02:04:21 IP
Glad to hear it works :)