Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    glenveegee
    @glenveegee
    What is your input to the jmespath search function and what does your expression look like
    varajgandhi
    @varajgandhi
    image.png
    currently, params take 0-9 as the first digit for a phone number but I need to change the pattern for the starting digit , it must accept either 8 or 9
    glenveegee
    @glenveegee
    Ah. Don't think this has anything to do with JMESPath but fwiw your regex could be written as ^[89][0-9\-]*$. The regex in the image isn't particularly good because it permits a telephone number like 8------------------------5
    You might want to rewrite that regex anyway to make it stricter
    From your initial question I see the regex you started with though ^[8-9]\d{7}$
    varajgandhi
    @varajgandhi
    yes, it doesn't work
    ^[89][0-9]\d{7}*$ also not working
    glenveegee
    @glenveegee
    This is probably because you aren't setting multiline flags
    you should just be able to do [89]\d{7}
    if you can't set flags
    varajgandhi
    @varajgandhi
    [89]\d{7} single \ can't accept in json and also 2-8 digits must in 0-9
    glenveegee
    @glenveegee
    escape it with another slash
    [89]\\d{7}
    If you want yo use the form ^[89]\\d{7}$ then somewhere in your code you should be doing new Regex(params, 'm')
    varajgandhi
    @varajgandhi
    okay, it's only for the first digit, what about 2 to 8 digits?
    glenveegee
    @glenveegee
    What is the format of the phone number
    What are the possible formats should I say
    varajgandhi
    @varajgandhi
    the first number must start with 8 or 9 and 2 to 8 digits accept 0 to 9
    glenveegee
    @glenveegee
    [89]\\d{2,8}
    varajgandhi
    @varajgandhi
    i will try
    not working ..
    glenveegee
    @glenveegee
    Any error or hint why?
    varajgandhi
    @varajgandhi
    throws error
    glenveegee
    @glenveegee
    which is?
    varajgandhi
    @varajgandhi
    image.png
    glenveegee
    @glenveegee
    And which box is being validated by that regex
    ^\+\d{2}|[89][0-9]{7}$
    varajgandhi
    @varajgandhi
    image.png
    this field only
    glenveegee
    @glenveegee
    Either <plus> with 2 digits or eight digits starting with 8 or 9
    varajgandhi
    @varajgandhi
    either digits starting with 8 or 9
    glenveegee
    @glenveegee
    If that's the case then you don't need the 2 to 8 condition
    Also if you definitely don't want to have a number longer than 8 digits you're going to have to use the multiline flag
    lastly in case the slash \ characters are causing trouble you could set it as follows:
    ^[89][0-9]{7}$
    if that doesn't work then there's something else going on.
    Make sure you're trimming values before trying to match them
    but other than that the regex above will only match a maximum of 8 digits where the starting digit is either an 8 or a 9
    varajgandhi
    @varajgandhi
    okay , i will try
    its not working,,anyway thank you for your timely support..
    glenveegee
    @glenveegee
    :thumbsup:
    You could always try confirming if there's something else going on by setting a very loose regex
    .*
    If that fails then there's definitely something screwed
    and if that passed you could slowly build up the regex to determine what exactly is causing the problem
    varajgandhi
    @varajgandhi
    Default validation takes for a phone number field, based on country code starting number validation, currently 3,6,8,9 accepts in the first digit, but the client wants only 8 or 9 as a starting digit. so only am tried to override the validation..
    glenveegee
    @glenveegee
    Perhaps try something like a regex playground to work out what you need based on what you have
    varajgandhi
    @varajgandhi
    yeah already am using this one..anyway thank you so much glen