thinking_hydrogen
thinking_hydrogen

Reputation: 189

Regular Expression to match English and Non English characters

I am trying to match a sentence that contains both English and Non English characters but does not contain pure numeric including decimals.

Example - Should match::

Renforcé-Bettwäschegar BLUMIRA123

Not match::

999.99

The following code matches everything that's not contained in the ASCII characters -

[^\u0000-\u0080]+

This is all I have at the moment. Any help will be much appreciated.

Thank you.

Upvotes: 0

Views: 5779

Answers (4)

thinking_hydrogen
thinking_hydrogen

Reputation: 189

Thanks for the inputs. The below regex seem to work for me.

^([x00-\xFF]+[a-zA-Z][x00-\xFF]+)*

Upvotes: 0

psxls
psxls

Reputation: 6935

First of all I'll assume that you have split your text into sentences. Then try this:

!/(?:^| )[0-9]+(?:\.[0-9]+)?(?: |$)$/.test(sentence);

For example, this is the returned result for each of the below sentences:

Renforcé-Bettwäschegar BLUMIRA123 //true
999.99                            //false
Another test                      //true
Hi this is a test 124             //false
Hi this is a test 124.23          //false

Upvotes: 2

mtanti
mtanti

Reputation: 834

See if this works:

.*([a-zA-Z].*[àáâäåÀÁÂÃçÇêéëèÊËÉÈïíîìÍÌÎÏñÑöòõóÓÔÕÖÒšŠúüûùÙÚÜÛÿŸýÝžŽ]|[àáâäåÀÁÂÃçÇêéëèÊËÉÈïíîìÍÌÎÏñÑöòõóÓÔÕÖÒšŠúüûùÙÚÜÛÿŸýÝžŽ].*[a-zA-Z]).*

Upvotes: 2

seldon
seldon

Reputation: 1027

This should do the trick

!/^[0-9.]+$/.test(s)

Please note that will match only numbers and decimals, so you need to negate it (the !)

Upvotes: 1

Related Questions