简体   繁体   中英

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.

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

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 !)

查看是否可行:

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM