Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

javascript - 拉丁语中第一个字符的正则表达式不起作用。 为什么? [重复](Regular expression with first character in latin is not working. Why? [duplicate])

I have a text where I would like to find different words.

(我有一个想在其中找到其他单词的文本。)

The following text is in Portuguese, Brazil, and serves only as a test case:

(以下文本是巴西葡萄牙语,仅用作测试用例:)

Um dia eu conheci Pedro álvares Cabral, e descobri muitas informa??es interessantes.

To find any of the words in the text, I am using the following regular expression:

(要查找文本中的任何单词,我使用以下正则表达式:)

/(Cabral)/i // Finds Cabral
/(dia)/i    // Finds dia
/(Pedro)/i  // Finds Pedro
Etc...

If I need to find more than one word, I do as follows:

(如果需要查找多个单词,请执行以下操作:)

/(informa??es|muitas)/ig

I am testing the functionality of the expression in both JavaScript and using this online utility .

(我正在JavaScript和使用此在线实用程序中测试表达式的功能。)

JavaScript code example:

(JavaScript代码示例:)

 var input = "Um dia eu conheci Pedro álvares Cabral, e descobri muitas informa??es interessantes." var matchRegExp = new RegExp("\\b(coNHECi)\\b", "i"); if(regs = matchRegExp.exec(input)) { console.log('OK'); } else { console.log('NOPE'); } 

THE PROBLEM(问题)

All the words I put into the expression are found, except álvares .

(找到我在表达式中输入的所有单词,除了álvares 。)

For example, I cannot find the word with the following expression:

(例如,我找不到具有以下表达式的单词:)

/(álvares)/i

If I remove the á character, lvares is found.

(如果删除á字符, lvares找到lvares 。)

I would like to:

(我想要:)

  1. To know why and for what reason I can't find álvares .

    (要知道为什么以及为什么找不到álvares 。)

  2. To know how I can find any word in a text that has the following characters: áàa?áà??éèêéèêíì?íì?óò??óò??úù?úù????? regardless of whether these characters represent the first, last, or any letter of a word.

    (要知道如何在具有以下字符的文本中找到任何单词:áà?áà?ééêééêeêíì??íì?óò??ò??ò??ú?úù??úù??????,无论这些字符代表单词的第一个,最后一个还是任何一个字母。)

  ask by Loa translate from so

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

1 Reply

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...