Perl regular expression for an English word

I need a regular expression that will find something similar to an English word. In particular, I want the expression to match the string:

1) only letters; and

2) at least two different letters. (I intentionally exclude one-letter words.)

So, I am looking for something that matches theand abracadabra, but not aaa.

Any help is greatly appreciated.

+3
source share
2 answers

May \b(\w*(\w)\w*(?!\2)\w+)\bwork for you. It processes the examples you provide.

\w , - , , (?!\2). , , . \w* . \b , .

http://www.rubular.com/r/pwjGi9eLf5

, - , . . , .

+7

Lingua:: EN:: Splitter:

use strict; use warnings;
use Lingua::EN::Splitter qw(words);

my @words = words $input_text;
print @words;
+4

Source: https://habr.com/ru/post/1783990/


All Articles