• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Reg Exp Question

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    Reg Exp Question

    I can never work this stuff out.

    I am looking for a reg exp that only takes 9 numbers, what I have just now is "\d{9}" and it is letting . - and spaces through.

    Anyone know a expression that suits?

    Cheers.

    #2
    Where are you evaluating your regexp?
    In any case did you try [0-9]{9} or even [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] ?

    Comment


      #3
      Originally posted by yasockie View Post
      Where are you evaluating your regexp?
      In any case did you try [0-9]{9} or even [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] ?
      Java server faces code, validateRegExpr tag

      [0-9]{9} looks promising, cheers.

      I look at reg exp about once a year and always spend 10 minutes trying to get my head round it.

      Comment


        #4
        Originally posted by minestrone View Post
        Java server faces code, validateRegExpr tag

        [0-9]{9} looks promising, cheers.

        I look at reg exp about once a year and always spend 10 minutes trying to get my head round it.
        Same with me. Have read tons of stuff to make myself an expert at it but still cannot get my head around it at times. It really is the work of devil.
        Vote Corbyn ! Save this country !

        Comment


          #5
          I put off learning this stuff for 20 years in IT, but recently was forced to for a gig. It's actually pretty clever.

          This I found very helpful:

          Regular Expressions Reference - Basic Syntax

          Is it a string in Java? I.e. do you mean: "\\d{9}"?

          Failing that, I've always found it's better to make it match the start and end:

          ^\d{9}$
          Will work inside IR35. Or for food.

          Comment


            #6

            Comment

            Working...
            X