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

How to create a ReGex that matches separated words inside a square brackets?

  • Thread starter Thread starter Stopfield
  • Start date Start date
S

Stopfield

Guest
I have the following string:

  • [I need some fresh air H2O].

What's the RegEx that matches the following words?

  • I, need, some, fresh, air, H2O.

Basically, each word inside the square brackets. I searched everywhere, couldn't find it. Every result points to a whole match, such as I need some fresh air H2O (check links below).

Can anyone help?

I'm currently at this RegEx:

  • (?<=\[).+?(?=\])

But it captures the whole sentence:

  • I need some fresh air H2O

I'm using the https://regexr.com/ engine (I assume it's javascript), but any engine pattern would suffice.

Related Questions​


Regular expression to extract text between square brackets

regex include text inside brackets

<p>I have the following string:</p>
<ul>
<li><code>[I need some fresh air H2O]</code>.</li>
</ul>
<p>What's the RegEx that matches the following words?</p>
<ul>
<li><code>I</code>, <code>need</code>, <code>some</code>, <code>fresh</code>, <code>air</code>, <code>H2O</code>.</li>
</ul>
<p>Basically, each word inside the square brackets. I searched everywhere, couldn't find it. Every result points to a whole match, such as <code>I need some fresh air H2O</code> (check links below).</p>
<p>Can anyone help?</p>
<p>I'm currently at this RegEx:</p>
<ul>
<li><code>(?<=\[).+?(?=\])</code></li>
</ul>
<p>But it captures the whole sentence:</p>
<ul>
<li><code>I need some fresh air H2O</code></li>
</ul>
<p>I'm using the <a href="https://regexr.com/" rel="nofollow noreferrer">https://regexr.com/</a> engine (I assume it's javascript), but any engine pattern would suffice.</p>
<h6>Related Questions</h6>
<p><a href="https://stackoverflow.com/questions...ssion-to-extract-text-between-square-brackets">Regular expression to extract text between square brackets</a></p>
<p><a href="https://stackoverflow.com/questions/22622457/regex-include-text-inside-brackets">regex include text inside brackets</a></p>
 

Latest posts

Top