Skip to Content Skip to Menu

Regular expression?

  • fribse2011
  • fribse2011
  • OFFLINE
  • Posts: 921
  • Thanks: 79
  • Karma: 8
12 years 1 month ago #197216 by fribse2011
Regular expression? was created by fribse2011
Hi Guys

I'm trying to add a regular expression to auto action
It should match for
a year between 2011 and 2100 OR a text, so I built this as a first, simple attempt:
(2[0|1]\d{2}|Text)

But I don't see that it matches in CB.
Also, I want to make sure that it always matches from the start.

What am I doing wrong?

Best regards
Fribse

Frømandsklubben Nikon, www.nikondyk.dk
We're a volunteer driven diving club in Ishøj, Denmark.
Har du brug for en dykkerklub der rummer alle, så kom ned til os.

Please Log in or Create an account to join the conversation.

  • fribse2011
  • fribse2011
  • OFFLINE
  • Posts: 921
  • Thanks: 79
  • Karma: 8
12 years 1 month ago #197227 by fribse2011
Replied by fribse2011 on topic Re: Regular expression?
I think one of my problems is that it's a multiselect field, so I guess I should enable it to contain more than one pattern, something like
((20[0-9]{2})|Æresmedlem)+

But I still can't make it match

Best regards
Fribse

Frømandsklubben Nikon, www.nikondyk.dk
We're a volunteer driven diving club in Ishøj, Denmark.
Har du brug for en dykkerklub der rummer alle, så kom ned til os.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 68625
  • Thanks: 9109
  • Karma: 1434
12 years 1 month ago #197241 by krileon
Replied by krileon on topic Re: Regular expression?
REGEX doesn't work too well for matching date ranges. For example your current REGEX will match between 2000-2099. You may want to try 2(?:0[0-9]{2}|100) to give 2000-2100.

Multi-selects always store to database as delimiter divided. Example as follows.

value1|*|value2|*|value3

Your REGEX also has no delimiter so it'll never execute properly and your site when trigger is actually erroring out. Example as follows.

/((?:2(?:0[0-9]{2}|100))|(?:Text))+/

A good REGEX resource can be found at the below link.

www.regular-expressions.info/


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • fribse2011
  • fribse2011
  • OFFLINE
  • Posts: 921
  • Thanks: 79
  • Karma: 8
12 years 1 month ago #197284 by fribse2011
Replied by fribse2011 on topic Re: Regular expression?
Hi Kyle

Thanks for the link.

Do you know of a good tester I can use to test my expressions?
How do I test for an empty string or text (single select), ie. so it matches
""
"Ikke medlem"

But not
"Senior"
"Junior"
"Æresmedlem"
"Støtte"

I was thinking
/(?:Ikke medlem)/

But that doesn't seem to trigger on empty?

Best regards
Fribse

Frømandsklubben Nikon, www.nikondyk.dk
We're a volunteer driven diving club in Ishøj, Denmark.
Har du brug for en dykkerklub der rummer alle, så kom ned til os.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 68625
  • Thanks: 9109
  • Karma: 1434
12 years 1 month ago #197291 by krileon
Replied by krileon on topic Re: Regular expression?
Several free online solutions available with a quick Google search. Examples as follows.

gskinner.com/RegExr/
www.regular-expressions.info/javascriptexample.html
regexpal.com/

Personally I use RegexBuddy, which is a commercial product (well worth it if you use REGEX/GREP regularly).


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum

Facebook Twitter LinkedIn