0

I am having a weird situation where in I am using regex expression to strip down the HTML tags from my text

I have the following text:

<div align="center">​test_gautam</div>

which on application of the following regex

var regex = /(<[^>]*>)/ig;
var CommentText = editor.getValue().replace(regex, "");

Gives me

"​test_gautam"

This looks fine but on careful examination I found out that there is an invisible character between first quote and t. Due to this my other regex is failing. Does anyone have any idea about how to get rid of this invisible character?

to check the invisible character copy the following text and paste in notepad

"​test_gautam"
2
  • Doesn't your editor have a method to get the pure text without tags? Commented Feb 25, 2014 at 13:03
  • Notepad++ shows no "invisibile char". Also pls tag the programm language you're using. Commented Feb 25, 2014 at 13:08

1 Answer 1

2

var regex = /(<[^>]*>)[^a-zA-Z0-9]*/ig;

Should grab anything which isn't a letter/number and comes after the <

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.