Question

My question is simple:

How do I make the use of JavaScript regex to detect whether a #hashtag is being entered in the input element? I have a function to convert the hashtag into a clickable link but it's PHP. I want a similar function but in jQuery the reason is that if a hashtag is entered then I can send a value to the PHP processor form.

Sorry there is no code as I dont know much about JavaScript regex, also, I could not find any good tutorials.

Was it helpful?

Solution

You are looking for this: (#\w*)

function hasNonStandard(inputElem) { 
    return /[#\w*]/.test(inputElem.value);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top