正则表达式 - 所有语言都一样吗? [英] regular expressions - same for all languages?

查看:287
本文介绍了正则表达式 - 所有语言都一样吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

语言之间的正则表达式是否相同?

is the regexp the same between languages?

例如。如果我想在javascript中使用它,我是否必须专门为javascript搜索regexp。因为我得到了一些备忘单。它只是说正则表达式。

for example. if i want to use it in javascript, would i have to search for regexp for javascript specifically. cause i got some cheat sheets. it just says regular expression.

我想知道我是否可以在所有语言,php,javascript等上使用它。

i wonder if i could use this on all languages, php, javascript and so on.

推荐答案

基本知识大致相同,但由于PHP使用PCRE(Perl兼容正则表达式),因此引擎支持语言,PHP和JavaScript之间存在一些差异。

The basics are mostly the same but there are some discrepancies between which engine powers the language, PHP and JavaScript differ since PHP uses PCRE (Perl Compatible Regular Expressions).

PHP还有POSIX兼容的正则表达式引擎( ereg _ *函数),但不推荐使用。

PHP also has the POSIX-compatible regex engine (ereg_* functions), but that is deprecated.

如果您还没有使用它,我建议您尝试 RegexBuddy 。它可以在几个正则表达式引擎之间进行转换。

If you don't already use it, I suggest you try RegexBuddy. It can convert between several Regex engines.

你可以找到 Mac上RegexBuddy的替代方案

这篇关于正则表达式 - 所有语言都一样吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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