我对PHP很陌生,对正则表达式也很陌生。我目前正在尝试编写一个正则表达式,以确保所有字符都是Alpha数字,并且接受其他字符。我想接受áéíóúuüÚ\x{e 010}和@.+-。接受所有字母数字字符和符号@.+-。我用的短语是:
if (!preg_match("!^[\w@.-]*$!")
此外,在我继续发言之前,我想补充一下。这些值都是从表单输入中获取的,它们都应该是一个单词短语(就像在空格中一样)。好,现在让我们继续!:D现在,我也想抓住字符áéíúúüas。当我使用这个短语时:
if (!preg_match("/[\wáéíñóúüÁÉÍÑÓÚÜ@.\+-]
土耳其字符Şİ不受支持。累死了。
<?php
header('Content-Type: text/html; charset=utf-8');
$test = "azAZ09andSpace supported but this turkish characters Ş İ Ö Ü like not supported";
//So it goes to the "else block".
if (preg_match('/^[a-zA-Z0-9 ]+$/', $test)){
echo "ma
用Regex找到句子的第一个字母和符号。在句子的开头,有时是字母,有时是数字。
15. Lorem ipsum is placeholder text
B. Lorem ipsum is placeholder text
C.Lorem ipsum is placeholder text
D . Lorem ipsum is placeholder text
E,Lorem ipsum is placeholder text
我写了这样的东西:
[\dga-zA-Z.]{1\s}
但并不是每句话都适用。此外,它不检测第一个字母/数字与带有句子的符号之间是否有空格。
我在哪里搞错了?
此外
我有一个简单的问题,我是PHP的新手。
我在PHP中有这个示例字符串:
this is a test sample thing
text @INEEDTOCHANGEHERE blah blah blah
this is a test sample thing
text @INEEDTOCHANGEHERE blah blah blah
this is a test sample thing
text @INEEDTOCHANGEHERE blah blah blah
...
我需要从字符串中更改所有的"INEEDTOCHANGEHERE“。
这不取决于这之后的太空焦。
所
为了拆分一根线我想出了..。
<php
preg_match_all('/(\w)|(,.!?;)/', "I'm a little teapot, short and stout.", $matches);
print_r($matches[0]);
我认为这将分隔每个单词(\w)和指定的标点符号(,.!?;)。例如:["I'm", "a", "little", "teapot", ",", "short", "and&
我有像这样的字符串:{$foo.bar}和{$foo.bar.anything}
位置:foo AND bar AND anything === alphanumeric
我想通过preg_match(regular expression)在PHP中匹配上面两个字符串,除了那些没有任何点for example : {$foo}的字符串
非常感谢您的帮助,谢谢。