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

Extract only words using regex

  • Thread starter Thread starter Ankit Tiwari
  • Start date Start date
A

Ankit Tiwari

Guest
I want to extract only words. The word should not contain any number or any special character attached to it, e.g. (64-bit), WebView2, x86_64. Current regex is able to ignore WebView2 and x86_64 but in the case of (64-bit) it's returning me bit, which I don't want. I want to exclude it because it contains numbers with -,(,) characters.

I've this input data:

Code:
Brave
Google Chrome
Microsoft Edge WebView2 Runtime
Robo 3T 1.4.4
WinRAR 7.01 (64-bit)
Python 3.12.3 Core Interpreter (64-bit)

and this regex:

Code:
\b[a-zA-Z]+\b

above regex return this result

Code:
['Python', 'Core', 'Interpreter', 'bit']

instead of the expected:

Code:
['Python', 'Core', 'Interpreter']
<p>I want to extract only words. The word should not contain any number or any special character attached to it, e.g. <code>(64-bit)</code>, <code>WebView2</code>, <code>x86_64</code>. Current regex is able to ignore <code>WebView2</code> and <code>x86_64</code> but in the case of <code>(64-bit)</code> it's returning me <code>bit</code>, which I don't want. I want to exclude it because it contains numbers with <code>-,(,)</code> characters.</p>
<p>I've this input data:</p>
<pre><code>Brave
Google Chrome
Microsoft Edge WebView2 Runtime
Robo 3T 1.4.4
WinRAR 7.01 (64-bit)
Python 3.12.3 Core Interpreter (64-bit)
</code></pre>
<p>and this regex:</p>
<pre><code>\b[a-zA-Z]+\b
</code></pre>
<p>above regex return this result</p>
<pre><code>['Python', 'Core', 'Interpreter', 'bit']
</code></pre>
<p>instead of the expected:</p>
<pre><code>['Python', 'Core', 'Interpreter']
</code></pre>
 

Latest posts

M
Replies
0
Views
1
MOHAMED AMIIN ABDI AADAN
M
Top