正则表达困境 [英] Regular expression woes

查看:64
本文介绍了正则表达困境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定在哪里发布这个问题,因为它涵盖了很多

平台,但由于平台不相关,所以这里......


我正试图(更好地拉我的头发)构建一个常规的

表达式字符串,其中包含以下内容:匹配输入字符串

不以字符http开头。例如


例如

" this string" - 匹配

" this http string" - 匹配

" http-and-a-bit-more-text" - 不匹配

" ht" - 匹配

"" - 比赛


我尝试了类似^ [^(^ http)]的东西,但是这给了

最后2没有匹配。任何想法? - 我真的很感激!

干杯

马克

解决方案

< blockquote>" Mark(新闻)" <是ne ** @ mail.adsl4less.com>在消息中写道

新闻:11 ********************* @ c13g2000cwb.googlegro ups.com ...

我不太确定在哪里发布这个问题,因为它涵盖了这么多的平台,但由于平台不相关,所以这里......




不正确。该平台非常相关。正则表达式

不是跨语言的常量。 Perl正则表达式不是

和Javascript正则表达式不一样PHP正常表达式。


选择一个或者另一方,告诉我们你正在尝试*做什么,以及在你正在做什么的b $ b环境中,然后有人可以帮助你。

Paul Lalli


2005年2月4日星期五07:19:44 -0800,Mark(新闻)写道:

我正在尝试(更好地拉出我的头发)构建一个常规的表达式字符串,其中包含以下内容:匹配,如果输入字符串
不以字符http开头;。例如

例如
此字符串 - 匹配
此http字符串 - 匹配
http-and-a-bit-more-text - 不匹配
ht - 匹配
"" - 匹配




如果字符串以http开头,则不匹配:


str!~m / ^ http /

-leendert bottelberghs


I''m not really sure where to post this question as it covers so many
platforms, but as the platform isn''t relevant, here goes...

I''m trying to (pulling my hair out more like) construct a regular
expression string that says the following: "match if the input string
does not start with the characters http". E.g.

e.g.
"this string" - match
"this http string" - match
"http-and-a-bit-more-text" - no match
"ht" - match
"" - match

I''ve tried something like ^[^(^http)] but this gives no match on the
last 2. Any ideas? - I''d really appreciate it!
Cheers
Mark

解决方案

"Mark (News)" <ne**@mail.adsl4less.com> wrote in message
news:11*********************@c13g2000cwb.googlegro ups.com...

I''m not really sure where to post this question as it covers so many
platforms, but as the platform isn''t relevant, here goes...



Incorrect. The platform is exceedingly relevant. Regular expressions
are not a constant across languages. Perl regular expression are not
the same as Javascript regular expressions are not the same as PHP
regular expressions.

Choose one or the other, tell us what you''re *trying* to do, and in what
environment you''re doing it, and then someone can help you.

Paul Lalli


On Fri, 04 Feb 2005 07:19:44 -0800, Mark (News) wrote:

I''m trying to (pulling my hair out more like) construct a regular
expression string that says the following: "match if the input string
does not start with the characters http". E.g.

e.g.
"this string" - match
"this http string" - match
"http-and-a-bit-more-text" - no match
"ht" - match
"" - match



So don''t match if the string starts with "http":


str !~ m/^http/
-leendert bottelberghs


这篇关于正则表达困境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆