0

Consider the following snippet of code:

<div align="Left">
<font style='font-size:17pt; font-family:Times New Roman;color:#000000;'>
<textformat tabstops="[20]" leftmargin="0">Hi all</textformat>
</font>
</div>

I want to extract string between "font-size" and "pt" i.e it should out me a decimal "17" using javascript.
Can this can be achieved using regular expression.

Thanks in advance,
Amit

2 Answers 2

2

Yes.

var pt = string.match(/font-size:([\d.])+pt/)[1];

What do you want to do with that?

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

Comments

0

In the case you just want to get the font size of the respective element I would recommend not relying on parsing the string but rather access this property by using the DOM – as for example something like:

document.getElementsByTagName('font')[0].style.fontSize

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.