문제

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