Note: Forums will be making significant UX changes to address key usability improvements surrounding search, discoverability and navigation. To learn more about these changes please visit the announcement which can be found HERE.
Regular expression- setting the max length of a particular word

Con risposta Regular expression- setting the max length of a particular word

  • martedì 31 luglio 2012 12:40
     
     

    hey all,

    I have been creating a pattern for a url which is something like (https?://)?(www\.)?[a-zA-Z](\.)[a-zA-Z]+(\.)[a-zA-Z]+(/)[a-zA-Z0-9]+(/)[a-zA-Z0-9]. Now the string that matches this pattern will be something like https://thevitruvianAnalogy.myname.com/sites/subsite

    Now i know how to limit the size of this string by concatenating something like {30,100} at the end of this pattern which would mean that this string should be atleast 30 letters long and at max 100 letters.

    NOW THE Question is how could i restrict the length of a single word. Like in the above example, how can i check the length of myname or sites or subsite, one of them but not all of them.

    Regards,

    Nishant

Tutte le risposte

  • martedì 31 luglio 2012 12:42
     
     

    Would you please check-out below thread

    http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvb/thread/e6411823-f932-4cc2-a8b3-e409df91ea68


    Regards,
    Ahmed Ibrahim
    SQL Server Setup Team
    My Blog
    This posting is provided "AS IS" with no warranties, and confers no rights. Please remember to click "Mark as Answer" and "Vote as Helpful" on posts that help you.
    This can be beneficial to other community members reading the thread.

  • martedì 31 luglio 2012 12:45
     
     
    Just need to add {0,50} for example. This will define that user can digit until 50 digits, afther that regex will get false value.

    Web Developer

  • mercoledì 1 agosto 2012 09:16
     
     Con risposta

    Thank you guys. I think i got the answer. It was in my knowledge all along but i wasnt able to test it. If in the following pattern you want to check the value of the last word (https?://)?(www\.)?[a-zA-Z](\.)[a-zA-Z]+(\.)[a-zA-Z]+(/)[a-zA-Z0-9]+(/)[a-zA-Z0-9] then all we need to do is put that part of the expression in brackets and do the following ([a-zA-Z0-9]{5,30}) i.e. add the following {a,b} where a is the min length and b is the max length of that particular word.

    Regards,

    Nishant