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.

有帮助吗?

解决方案

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

function hasNonStandard(inputElem) { 
    return /[#\w*]/.test(inputElem.value);
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top