OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Convert PHP regex to JS regex [closed]

  • Thread starter Thread starter Aleksei Merzliakov
  • Start date Start date
A

Aleksei Merzliakov

Guest
what I need is a regular expression for parsing meta tag attributes. String will be like this one

Code:
<meta name="someName" content="someContent" />

I have this perfectly working PHP regex:

Code:
/<meta\s+name="(?P<name>.*?)".*?content="(?P<content>.*?)".*?>/gm

It gives me name and content in groups. And I know that for now JS also support grouping in regex, but I cannot convert PHP regex to Javascript regular expression due to lack of experience with regex. Can someone help me with that?

And I cannot use DOMParser unfortunately if someone want to suggest this solution because this is server code.

<p>what I need is a regular expression for parsing meta tag attributes. String will be like this one</p>
<pre><code><meta name="someName" content="someContent" />
</code></pre>
<p>I have this perfectly working PHP regex:</p>
<pre><code>/<meta\s+name="(?P<name>.*?)".*?content="(?P<content>.*?)".*?>/gm
</code></pre>
<p>It gives me name and content in groups.
And I know that for now JS also support grouping in regex, but I cannot convert PHP regex to Javascript regular expression due to lack of experience with regex. Can someone help me with that?</p>
<p>And I cannot use DOMParser unfortunately if someone want to suggest this solution because this is server code.</p>
 

Latest posts

M
Replies
0
Views
1
MusicLovingIndianGirl
M
Q
Replies
0
Views
1
quora question
Q
Top