I have a very simple question, i dont know why it ...
# suitescript
v
I have a very simple question, i dont know why it does not work for me. A variable must consist of 4 numbers or the text β€˜STDP’. I should check this in if condition. if(!(section2.length === 4) || !numbers.test(section2) || (section2 !== 'STDP')) This is my code
s
Try turning it round: if((section2.length === 4) && numbers.test(section2)) || section2 === 'STDP')
v
no its not working.
s
What do each of the sections of the test expression return?
I'm not familiar with "numbers.test" is that something you have created?
v
its the link that you sent.
var numbers = /^[0-9]/;
d
regex my friend, regex
v
how to use regex?
i am banging my head into the laptop for hours for this simple error
j
how to use regex?
😐
d
Eesh ... ok, here's a freebee ...
/^STDP$|^\d{4}$/
πŸ™‚ 1
v
Thank you it is working fine
πŸ‘Œ 1