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.
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.
Share Improve this question asked Dec 19, 2013 at 14:03 thinking_hydrogenthinking_hydrogen 1891 gold badge5 silver badges15 bronze badges 2- So it should match strings which contain at least one English letter ([a-zA-Z]) and one accented/diacritic letter ([àáâäåÀÁÂÃçÇêéëèÊËÉÈïíîìÍÌÎÏñÑöòõóÓÔÕÖÒšŠúüûùÙÚÜÛÿŸýÝžŽ])? Is there a need for non-ASCII characters? – mtanti Commented Dec 19, 2013 at 14:29
- mtanti - Thanks for your ment. There's no need for non-ASCII characters. Thank you. – thinking_hydrogen Commented Dec 19, 2013 at 14:39
4 Answers
Reset to default 2See if this works:
.*([a-zA-Z].*[àáâäåÀÁÂÃçÇêéëèÊËÉÈïíîìÍÌÎÏñÑöòõóÓÔÕÖÒšŠúüûùÙÚÜÛÿŸýÝžŽ]|[àáâäåÀÁÂÃçÇêéëèÊËÉÈïíîìÍÌÎÏñÑöòõóÓÔÕÖÒšŠúüûùÙÚÜÛÿŸýÝžŽ].*[a-zA-Z]).*
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 !)
Thanks for the inputs. The below regex seem to work for me.
^([x00-\xFF]+[a-zA-Z][x00-\xFF]+)*
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745180431a4615392.html
评论列表(0条)