RegEx Question?

Discussion in 'Programming' started by amaze, Jan 9, 2009.

  1. #1
    Hi,

    I want to create a RegEx that looks for the following (the number 1 is any numeric digit):

    TL1
    TL11
    TL111
    TL1111
    TL11111
    TL111111
    TL1111111
    TL11111111

    Does that make sense?
     
    amaze, Jan 9, 2009 IP
  2. harrisunderwork

    harrisunderwork Well-Known Member

    Messages:
    1,005
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    135
    #2
    Try this

     TL[\d]+ 
    Code (markup):
     
    harrisunderwork, Jan 9, 2009 IP
    tarponkeith likes this.
  3. szalinski

    szalinski Peon

    Messages:
    341
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    what's the \d supposed to represent? i would have thought
    TL[0-9]+
    Code (markup):
     
    szalinski, Jan 9, 2009 IP
  4. harrisunderwork

    harrisunderwork Well-Known Member

    Messages:
    1,005
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    135
    #4
    It represents digits.
     
    harrisunderwork, Jan 9, 2009 IP
  5. rohan_shenoy

    rohan_shenoy Active Member

    Messages:
    441
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    60
    #5
    Do you want to detect the pyramid? or just any like with 'TL' sufffixed with numbers?
     
    rohan_shenoy, Jan 9, 2009 IP
  6. hassanahmad1

    hassanahmad1 Active Member

    Messages:
    150
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #6
    maybe ur looking for this :):

    ^TL[0-9]{1, 8}$

    checks that the number of digits must be in between 1 and 8
     
    hassanahmad1, Jan 9, 2009 IP
    amaze likes this.
  7. JosephineX

    JosephineX Peon

    Messages:
    49
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Was just about to post the same thing :rolleyes:
     
    JosephineX, Jan 11, 2009 IP
  8. amaze

    amaze Active Member

    Messages:
    594
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #8
    Thank you to all!
     
    amaze, Jan 15, 2009 IP