Results 1 to 10 of 10

Thread: Pattern

  1. #1
    mtyoung is offline Senior Member
    Join Date
    Dec 2008
    Location
    Hong Kong
    Posts
    473
    Rep Power
    10

    Default Pattern

    i have a Pattern ([_a-zA-Z]+[_0-9a-zA-Z-/]*[_0-9a-zA-Z]+)
    would catch general valid .... let said uri without file extension
    how can modify the pattern so that i would not match pattern ... let said ... "abc/ccd"?
    Last edited by mtyoung; 04-06-2009 at 12:33 PM.

  2. #2
    faisalcmpm is offline Member
    Join Date
    Feb 2009
    Posts
    22
    Rep Power
    0

    Default

    Well, ([_0-9a-zA-Z-/]*) is enough for your business.
    Now if u dont want "/" in your pattern just remove it
    i.e. ([_0-9a-zA-Z-]*)

  3. #3
    mtyoung is offline Senior Member
    Join Date
    Dec 2008
    Location
    Hong Kong
    Posts
    473
    Rep Power
    10

    Default

    faisalcmpm... why [_0-9a-zA-Z-/]* is enough? we should not accept input like "///aaa///aaa//"
    if remove "/", it can only handle the last part of uri... you know...

    current situation is "abc/ccd" matches [_a-zA-Z]+[_0-9a-zA-Z-/]*[_0-9a-zA-Z]+
    but i want to modify the pattern so that "abc/ccd" will not match but "abcd/ccd" still match the pattern
    Last edited by mtyoung; 04-06-2009 at 01:32 PM.

  4. #4
    faisalcmpm is offline Member
    Join Date
    Feb 2009
    Posts
    22
    Rep Power
    0

    Default

    Sorry..
    The thing is that am not that much expert in URI syntax.
    Still i didn't get your actual issue.
    U wants to mach "abc/ccd" but not "abcd/ccd" ,
    means u want to restrict the alphabet count to 3?

  5. #5
    mtyoung is offline Senior Member
    Join Date
    Dec 2008
    Location
    Hong Kong
    Posts
    473
    Rep Power
    10

    Default

    not related to uri syntax...

    i want to match most of pattern, ([_a-zA-Z]+[_0-9a-zA-Z-/]*[_0-9a-zA-Z]+)
    but in some of special pattern... may be a123/ccd, gae24edwegt34r/546/3246/1312 , i want them not to match

    so... my question is how to modify the ([_a-zA-Z]+[_0-9a-zA-Z-/]*[_0-9a-zA-Z]+) pattern, so that so pattern(self define maybe d25/232/afasdf/dfa will not match it)

  6. #6
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    10

    Default

    For a specific example, just handle them outside of the pattern - i.e. if you match one then ignore it.
    There's nothing you can do in the pattern unless you can characterise the pattern of strings you want to exclude.

  7. #7
    faisalcmpm is offline Member
    Join Date
    Feb 2009
    Posts
    22
    Rep Power
    0

    Default

    I agree with OrangeDog.
    U have to have a kind of similarity in those inputs which u want to exclude. Then only u can take advantage of Pattern

  8. #8
    mtyoung is offline Senior Member
    Join Date
    Dec 2008
    Location
    Hong Kong
    Posts
    473
    Rep Power
    10

    Default

    [^snv] will not include s, n, v
    so is there any method to exculde String, not char?

  9. #9
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    10

    Default

    In short, no. Regular expression work on a character-by-character basis.

  10. #10
    mtyoung is offline Senior Member
    Join Date
    Dec 2008
    Location
    Hong Kong
    Posts
    473
    Rep Power
    10

Similar Threads

  1. Star pattern help?
    By GeeKunMow in forum New To Java
    Replies: 13
    Last Post: 07-21-2011, 06:59 AM
  2. MVC Pattern
    By bubbless in forum New To Java
    Replies: 12
    Last Post: 03-14-2009, 10:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •