Regex validation for title field help

This topic contains 5 replies, has 3 voices, and was last updated by  Naveen Giri 4 years, 2 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #531331

    Fraser Johnson
    Expired Member
    Post count: 20

    Hi,

    Trying to force regex validation for the Title field of posts to match addresses of Australia (real estate site).

    Example:

    30 Chesterton Ave, Sydney NSW 2028

    Ideally, I’d like the spaces and comma after street type (in this case ‘ave’) to be strictly required. This is my (terrible) attempt at a regex line so far which doesn’t work for me:

    /^\d+\s[A-z]+\s[A-z]{1,4},+\s[A-za-z]+\s[A-Z]{1,5}+\s[0-9]{4}$/

    Thanks for any help!

    Fraser

    #531356

    Alex Rollin
    Moderator
    Post count: 27815

    Here is a tool that might help: https://www.regextester.com/93592

    #531531

    Fraser Johnson
    Expired Member
    Post count: 20

    Hi Alex,

    Turns out my regex expression wasn’t actually wrong, but the validation field does not need the’/’ character at the start and end of the expression.

    #531541

    Naveen Giri
    Moderator
    Post count: 1559

    Hi Fraser ,

    Please use only

    ^\d+\s[A-z]+\s[A-z]+

    It will work for you.

    Thanks

    #532268

    Fraser Johnson
    Expired Member
    Post count: 20

    Thankyou Naveen, all sorted!

    #532303

    Naveen Giri
    Moderator
    Post count: 1559

    Thanks for confirmation Fraser.
    have a nice day.

Viewing 6 posts - 1 through 6 (of 6 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket