pattern-matching

Biostrings gregexpr2 gives errors while gregexpr works fine

ε祈祈猫儿з 提交于 2021-02-10 15:38:43
问题 I'm replacing gregexpr with gregexpr2 to detect overlapping matches. When I try. >subSeq 3000-letter "DNAString" instance seq: ACACGTGTTCTATTTTCATTTGCTGACATTTTCTAGTGCATCATTTTTTATTTTATTTTCATT.... gregexpr2("TAAT|ATTA",subSeq) Error in matches[[i]] : subscript out of bounds whereas gregexpr("TAAT|ATTA",subSeq) works fine. What happened? 回答1: It is quite clear if you read gregexpr2 documentation: This is a replacement for the standard gregexpr function that does exact matching only. Standard

Biostrings gregexpr2 gives errors while gregexpr works fine

廉价感情. 提交于 2021-02-10 15:36:50
问题 I'm replacing gregexpr with gregexpr2 to detect overlapping matches. When I try. >subSeq 3000-letter "DNAString" instance seq: ACACGTGTTCTATTTTCATTTGCTGACATTTTCTAGTGCATCATTTTTTATTTTATTTTCATT.... gregexpr2("TAAT|ATTA",subSeq) Error in matches[[i]] : subscript out of bounds whereas gregexpr("TAAT|ATTA",subSeq) works fine. What happened? 回答1: It is quite clear if you read gregexpr2 documentation: This is a replacement for the standard gregexpr function that does exact matching only. Standard

Biostrings gregexpr2 gives errors while gregexpr works fine

萝らか妹 提交于 2021-02-10 15:36:15
问题 I'm replacing gregexpr with gregexpr2 to detect overlapping matches. When I try. >subSeq 3000-letter "DNAString" instance seq: ACACGTGTTCTATTTTCATTTGCTGACATTTTCTAGTGCATCATTTTTTATTTTATTTTCATT.... gregexpr2("TAAT|ATTA",subSeq) Error in matches[[i]] : subscript out of bounds whereas gregexpr("TAAT|ATTA",subSeq) works fine. What happened? 回答1: It is quite clear if you read gregexpr2 documentation: This is a replacement for the standard gregexpr function that does exact matching only. Standard

Troubles with encoding, pattern matching and noisy texts in R

谁说胖子不能爱 提交于 2021-02-10 14:36:56
问题 We are experiencing problems with encoding, pattern matching using texts automatically downloaded from the web. We need some help to understand where the problem lies and how to fix it. Personally, I must confess that after having read so many posts on the topic, I am completely confused :-) Our texts sometimes include: 1) disturbing Unicode (I have read this already (Automatically escape unicode characters ), but I am not sure in which way it can help with regular expressions) 2) weird

F# type test pattern matching: decomposing tuple objects

半腔热情 提交于 2021-02-10 14:19:57
问题 Just curious why I can't do this: let myFn (data : obj) = match data with | :? (string * string) as (s1, s2) -> sprintf "(%s, %s)" s1 s2 |> Some | :? (string * string * int) as (s1, s2, i) -> sprintf "(%s, %s, %d)" s1 s2 i |> Some | _ -> None How come? 回答1: See F# spec, section 7.3 "As patterns" An as pattern is of the form pat as ident Which means you need to use an identifier after as : let myFn (data : obj) = match data with | :? (string * string) as s1s2 -> let (s1, s2) = s1s2 in sprintf

Setting a relevant expression match to false in a do…while

╄→гoц情女王★ 提交于 2021-02-10 13:21:46
问题 I'm trying to write some very basic code, but I'm also challenging myself on regular expression. I've been able to muddle through the code up to a point, but where I'm really having a problem is that I'm trying to run a do...while loop while the expression is false. At this point in time I get absolutely no errors, but the do...while loop keeps running. I'm attaching the relevant code below, here's hoping it helps. Thank you in advance if (tollResponse == "yes") { Console.WriteLine("How much

VBA Excel Replace last 2 digits of number if occurs at beginning of string

好久不见. 提交于 2021-02-10 05:14:25
问题 I'm trying to replace the last two digits of number with " XX BLOCK " if it occurs at the start of the string and has more than 2 digits. I'm using the Microsoft VBScript Regular Expressions 5.5 reference. Dim regEx As New RegExp With regEx .Global = True 'Matches whole string, not just first occurrence .IgnoreCase = True 'Matches upper or lowercase .MultiLine = True 'Checks each line in case cell has multiple lines .pattern = "^(\d{2,})" 'Checks beginning of string for at least 2 digits End

VBA Excel Replace last 2 digits of number if occurs at beginning of string

守給你的承諾、 提交于 2021-02-10 05:14:13
问题 I'm trying to replace the last two digits of number with " XX BLOCK " if it occurs at the start of the string and has more than 2 digits. I'm using the Microsoft VBScript Regular Expressions 5.5 reference. Dim regEx As New RegExp With regEx .Global = True 'Matches whole string, not just first occurrence .IgnoreCase = True 'Matches upper or lowercase .MultiLine = True 'Checks each line in case cell has multiple lines .pattern = "^(\d{2,})" 'Checks beginning of string for at least 2 digits End

Extract IBAN from text with Python

ぐ巨炮叔叔 提交于 2021-02-08 15:10:28
问题 I want to extract IBAN numbers from text with Python. The challenge here is, that the IBAN itself can be written in so many ways with spaces bewteen the numbers, that I find it difficult to translate this in a usefull regex pattern. I have written a demo version which tries to match all German and Austrian IBAN numbers from text. ^DE([0-9a-zA-Z]\s?){20}$ I have seen similar questions on stackoverflow. However, the combination of different ways to write IBAN numbers and also extracting these

Extract IBAN from text with Python

老子叫甜甜 提交于 2021-02-08 15:08:51
问题 I want to extract IBAN numbers from text with Python. The challenge here is, that the IBAN itself can be written in so many ways with spaces bewteen the numbers, that I find it difficult to translate this in a usefull regex pattern. I have written a demo version which tries to match all German and Austrian IBAN numbers from text. ^DE([0-9a-zA-Z]\s?){20}$ I have seen similar questions on stackoverflow. However, the combination of different ways to write IBAN numbers and also extracting these