string-matching

How to check if matching text is found in a string in Lua?

自古美人都是妖i 提交于 2019-12-03 09:20:18
I need to make a conditional that is true if a particular matching text is found at least once in a string of text, e.g.: str = "This is some text containing the word tiger." if string.match(str, "tiger") then print ("The word tiger was found.") else print ("The word tiger was not found.") How can I check if the text is found somewhere in the string? You can use either of string.match or string.find . I personally use string.find() myself. Also, you need to specify end of your if-else statement. So, the actual code will be like: str = "This is some text containing the word tiger." if string

regex to match html tags with specific attributes

六眼飞鱼酱① 提交于 2019-12-03 04:01:44
I am trying to match all HTML tags that do not have the attribute "term" or "range" here is sample HTML format <span class="inline prewrap strong">DATE:</span> 12/01/10 <span class="inline prewrap strong">MR:</span> 1234567 <span class="inline prewrap strong">DOB:</span> 12/01/65 <span class="inline prewrap strong">HISTORY OF PRESENT ILLNESS:</span> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It

Using Java Regex, how to check if a string contains any of the words in a set ?

[亡魂溺海] 提交于 2019-12-03 02:40:38
问题 I have a set of words say -- apple, orange, pear , banana, kiwi I want to check if a sentence contains any of the above listed words, and If it does , I want to find which word matched. How can I accomplish this in Regex ? I am currently calling String.indexOf() for each of my set of words. I am assuming this is not as efficient as a regex matching? 回答1: TL;DR For simple substrings contains() is best but for only matching whole words Regular Expression are probably better. The best way to see

Regex returns string undefined

人走茶凉 提交于 2019-12-03 00:53:34
问题 I am trying to extract hash value from an magnet link but it returns undefined var tesst = "magnet:?xt=urn:btih:2B78EDFDDC87DC9605FB285997A80B787888C194&" var test = tesst.match(/magnet:\?xt=urn:btih:[a-z\d]{40}\&/im); alert (test[1]); I cant understand what I am doing wrong. 回答1: just mark what you want with capturing group: /^magnet:\?xt=urn:btih:([a-z\d]{40})\&$/im Also I recomend to not use regexp here. Try followed: tesst.split(':')[3].slice(0, -1); slice(0, -1) used for remove last '&',

Approximate String Matching - Machine Learning [closed]

流过昼夜 提交于 2019-12-02 23:37:51
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago . I have a requirement where my source data is in HDFS, and there is one field which contains skills of the users. Now the source file has all kind of skills attributed to a user for eg - MANAGEMENT , JAVA, HADOOP , PIG ,SQL, PERFORMANCE TUNING, C ,BUSINESS CONSULTING , SALES etc

How to subset data with advance string matching

ぐ巨炮叔叔 提交于 2019-12-02 22:24:49
I have the following data frame from which I would like to extract rows based on matching strings. > GEMA_EO5 gene_symbol fold_EO p_value RefSeq_ID BH_p_value KNG1 3.433049 8.56e-28 NM_000893,NM_001102416 1.234245e-24 REXO4 3.245317 1.78e-27 NM_020385 2.281367e-24 VPS29 3.827665 2.22e-25 NM_057180,NM_016226 2.560770e-22 CYP51A1 3.363149 5.95e-25 NM_000786,NM_001146152 6.239386e-22 TNPO2 4.707600 1.60e-23 NM_001136195,NM_001136196,NM_013433 1.538000e-20 NSDHL 2.703922 6.74e-23 NM_001129765,NM_015922 5.980454e-20 DPYSL2 5.097382 1.29e-22 NM_001386 1.062868e-19 So I would like to extract e.g. two

Using Java Regex, how to check if a string contains any of the words in a set ?

左心房为你撑大大i 提交于 2019-12-02 16:13:13
I have a set of words say -- apple, orange, pear , banana, kiwi I want to check if a sentence contains any of the above listed words, and If it does , I want to find which word matched. How can I accomplish this in Regex ? I am currently calling String.indexOf() for each of my set of words. I am assuming this is not as efficient as a regex matching? TL;DR For simple substrings contains() is best but for only matching whole words Regular Expression are probably better. The best way to see which method is more efficient is to test it. You can use String.contains() instead of String.indexOf() to

Regex returns string undefined

我是研究僧i 提交于 2019-12-02 14:40:57
I am trying to extract hash value from an magnet link but it returns undefined var tesst = "magnet:?xt=urn:btih:2B78EDFDDC87DC9605FB285997A80B787888C194&" var test = tesst.match(/magnet:\?xt=urn:btih:[a-z\d]{40}\&/im); alert (test[1]); I cant understand what I am doing wrong. just mark what you want with capturing group: /^magnet:\?xt=urn:btih:([a-z\d]{40})\&$/im Also I recomend to not use regexp here. Try followed: tesst.split(':')[3].slice(0, -1); slice(0, -1) used for remove last '&', you can use any other method, like slice(0, 40) , replace(/[^\w]/g, '') or any other. var test = tesst

Getting illegal character range in regex :java

对着背影说爱祢 提交于 2019-12-02 09:19:26
问题 I have a simple regex pattern that verifies names. But When I run it I get illegal character range error. I thought by escaping "\s" it will allow a space but the compiler is still complaining. public boolean verifyName(String name) { String namePattern = "^[\\p{L}]++(?:[',-\\s][\\p{L}]++)*+\\.?$"; return name.matches(namePattern); } and this is the error that i think shouldn't be occurring since a name might contain anny of these [',-\\s] so where am i not understanding? 回答1: You can't have

Extract numbers from String

时光总嘲笑我的痴心妄想 提交于 2019-12-02 07:16:31
问题 I have to parse a String to create a PathSegmentCollection. The string is composed of numbers separated by comas and/or (any) whitespaces (like newline, tab, etc...), also the numbers can be written using scientific notation. This is an example: "9.63074,9.63074 -5.55708e-006 0 ,0 1477.78" And the points are: P1(9.63074, 9.63074), P2(-0,555708, 0), P3(0, 1477.78) To extract numbers I use a regular expression: Dim RgxDouble As New Regex("[+-]?\b[0-9]+(\.[0-9]+)?(e[+-]?[0-9]+)?\b") Dim Matches