javascript - Regex returning null vs returning empty string -


My first stack overflow question! So let me know if I could run a better route to get this information / if I am surprised at writing my questions well in search of :) Meanwhile ... for the question!

Then I have a regex function:

  s = "banishing"; // This variable will be regex = / benisasilly (.) * /; Console.log (s.match (regex));  

And what I want to do is the log that has been added to "Benicasili" if it exists, and if the log tap is not the same. But what is happening is that it logs instead of an empty string, is there any way to include this functionality in a regex function, or should I just check it out of this function? Besides, is it really important? I mostly just wanted to do this because I have other reggae functions which I am using in the same system which is empty, so I like them all in the same output format. Thanks a lot! : D

EDIT: Make me a bit more clear. This is the output for which I am expecting:

  ['BeniciSilihhehee', 'ishe', index: 0, Input: 'Beniciously']]  

And then

  null  

If this does not work.

Currently, when it does not work, I get: ['Benicisiily', '', Index: 0, Input: 'BeniciSili']

It's really important for me, empty string vs. empty string that I want to return a blank string vs match match vs.

This is my first post as well.

Can you try to replace your regex

  regex = / benisasilly (. +)   

* returns an empty string because, * means that matching 0 or more characters using + means that the lower in the original string Must have at least 1 character attached.


Comments