Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
561 views
in Technique[技术] by (71.8m points)

javascript - 我不能不看后面就匹配这个正则表达式,而且我也不知道如何(I can't match with this Regular Expression without look behind, and I don't know How)

I am using regular expressions to create a simple JavaScript application.

(我正在使用正则表达式创建一个简单的JavaScript应用程序。)

I've looked at some answers here from the community, and unfortunately I'm still unable to create a regular expression that suits my specific case .

(我已经在社区中找到了一些答案,但是不幸的是,我仍然无法创建适合我具体情况的正则表达式。)

I apologize, but I have no mastery over regular expressions.

(我很抱歉,但是我对正则表达式没有精通。)

I wish I could solve my problem without using a reverse function, or any utility function if possible.

(我希望我可以不使用反向函数或任何可能的实用程序函数来解决问题。)

If this can only be solved with one, then that's fine, there's nothing to be done.

(如果这只能用一个解决,那就没关系了。)

THE PROBLEM(问题)

Consider the following text (it's in portuguese, Brazil, so accented characters need to be considered, like álvares, Liga??es, América, etc.):

(考虑以下文本(在葡萄牙语,巴西中使用,因此需要考虑带重音符号,例如álvares,Liga??es,América等):)

O Brasil é um país com muitos brasileiros. Alguns dizem Abrasil, outros nem tanto.

What I seek:

(我追求的是:)

"Brasil" true // Desired result
" Brasil" false
"brasil"eiros false
A"brasil" false

The regular expression currently used ( not correct ):

(当前使用的正则表达式( 不正确 ):)

([^w|^u0080-u00FF])(Brasil)(?![w|u0080-u00FF])

The part of the expression I'm having trouble with:

(我遇到的表达式部分:)

 ([^w|^u0080-u00FF])

The ( wrong ) result I am getting at the moment:

(我现在得到的( 错误 )结果是:)

" Brasil" // I just want "Brasil"

Bibliography(参考书目)

Even accepted, from what I could see , look behind is not yet widely implemented.

(从我所见 ,即使接受,回头观也尚未广泛实施。)

  ask by Loa translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...