SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Jan 2010
    Posts
    130
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    regex string without dash

    I want regex get string without dash ?? any help??

    for example

    gamal-hany

    gamal hany


    I want regex retrieve first one(gamal-hany)

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,312
    Mentioned
    178 Post(s)
    Tagged
    8 Thread(s)
    If you want to match some characters followed by a minus follwed by some characters, try this:

    Code:
    /^.+\-.+$/
    Code:
    console.log("gamal-hany".match(/^.+\-.+$/));
    ["gamal-hany", index: 0, input: "gamal-hany"]
    Code:
    console.log("gamal hany".match(/^.+\-.+$/));
    null
    HTH


Bookmarks

Posting Permissions

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