Regex for xls form

Hey Everyone,
Iam new to ODK and i am making my first xls form and i am stuck.I want to add regex for the website in my xls form that should allow the user to write http,https.co.in,.tv,.in. Right now i am using the regex: regex(.,'[a-zA-Z0-9]+.[a-zA-Z]+(.?[a-zA-Z0-9#]+/?)'), but it is allowing only.com but not .co.in etc. Please help.

Thank You

where you want to add this in your xml form.

Introduce your self here : Introduce yourself here!

Narendra

Are you just trying to regex against domain names?

This is non-trivial, but there's a lot of resources for this if you start looking around.
For example:
A preview of the Domain Name chapter of Regular Expression Cookbook
An example domain name regex, with debugging info

I always use https://regex101.com/ when I am building regular expressions. You can put all your test cases in the field below and then see what matches and what doesn't. (Be sure to include some counter-examples in your test cases.)

One thing to keep in mind, depending on your context, is that domain names can contain non-ASCII characters, including characters in nearly every international alphabet and even emoji.

2 Likes

Try this:

regex('^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$')

Lifted from here

Thank you so much for the reply, but still it is not taking http://,https://.

Ah. So are you trying to match domain names (e.g. "google.com") or simple URLs (eg https://google.com), or complex URLs (eg https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top). Or something else entirely?

"http" is a protocol. ".tv" and ".in" is - I suspect - intended to be a top-level domain name. And "https.co.in" rather falls into the bucket of 'something else entirely'... :confused:

I think you need to explain what exactly it is that you are trying to match against.