3

Any JavaScript RegEx experts care to help please??

Comments
  • 0
    https://regex101.com/r/DX0HRW/1 regex here

    it should match @nuv.ac.in in a string and it is working, perfect, but it is also working if the given string is @nuv.ac.innnnnnnnn and so on

    any expert help perhaps?
  • 2
    @dextel2 the @ is the key. Only one part matches that so only the part to the right of @ in the regex can match anything to the right in the string and no part of that right regex can match multiple n in the end
  • 2
    @dextel2 how about a "$" in the end?
  • 0
    @Voxera how can I fix it though??
  • 1
    and since you do not end the regex with $ it can partially match the string, thats why the last row matches but the trailing n is white, its not part of the match.

    Add $ in the end of the regex and it will not match the last one.
  • 1
    @dextel2 $ matches “end of line/file” and ^ matches beginning.
  • 0
    @Voxera @YouAreAPirate perfect solution , thank you guys
  • 4
    How is JavaScript at fault?
  • 1
    @JKyll personal opinion ☺️
Add Comment