matching

How can I extract a string between matching braces in Perl?

十年热恋 提交于 2019-11-26 23:15:23
问题 My input file is as below : HEADER {ABC|*|DEF {GHI 0 1 0} {{Points {}}}} {ABC|*|DEF {GHI 0 2 0} {{Points {}}}} {ABC|*|XYZ:abc:def {GHI 0 22 0} {{Points {{F1 1.1} {F2 1.2} {F3 1.3} {F4 1.4}}}}} {ABC|*|XYZ:ghi:jkl {JKL 0 372 0} {{Points {}}}} {ABC|*|XYZ:mno:pqr {GHI 0 34 0} {{Points {}}}} { ABC|*|XYZ:abc:pqr {GHI 0 68 0} {{Points {{F1 11.11} {F2 12.10} {F3 14.11} {F4 16.23}}}} } TRAILER I want to extract the file into an array as below : $array[0] = "{ABC|*|DEF {GHI 0 1 0} {{Points {}}}}"

Matching multiple columns on different data frames and getting other column as result

有些话、适合烂在心里 提交于 2019-11-26 20:57:34
问题 I got two big data frames, one ( df1 ) has this structure chr init 1 12 25289552 2 3 180418785 3 3 180434779 The other ( df2 ) has this V1 V2 V3 10 1 69094 medium 11 1 69094 medium 12 12 25289552 high 13 1 69095 medium 14 3 180418785 medium 15 3 180434779 low What I'm trying to do is to add the column V3 of df2 to df1 , to get the info of the mutation chr init Mut 1 12 25289552 high 2 3 180418785 medium 3 3 180434779 low I'm trying loading both into R and then doing a for loop using match but

select columns based on multiple strings with dplyr contains()

风格不统一 提交于 2019-11-26 19:48:49
问题 I want to select multiple columns based on their names with a regex expression. I am trying to do it with the piping syntax of the dplyr package. I checked the other topics, but only found answers about a single string. With base R: library(dplyr) mtcars[grepl('m|ar', names(mtcars))] ### mpg am gear carb ### Mazda RX4 21.0 1 4 4 ### Mazda RX4 Wag 21.0 1 4 4 However it doesn't work with the select/contains way: mtcars %>% select(contains('m|ar')) ### data frame with 0 columns and 32 rows What

String Pattern Matching In Java

送分小仙女□ 提交于 2019-11-26 19:45:46
问题 I want to search for a given string pattern in an input sting. For Eg. String URL = "https://localhost:8080/sbs/01.00/sip/dreamworks/v/01.00/cui/print/$fwVer/{$fwVer}/$lang/en/$model/{$model}/$region/us/$imageBg/{$imageBg}/$imageH/{$imageH}/$imageSz/{$imageSz}/$imageW/{$imageW}/movie/Kung_Fu_Panda_two/categories/3D_Pix/item/{item}/_back/2?$uniqueID={$uniqueID}" Now I need to search whether the string URL contains " /{item}/ ". Please help me. This is an example. Actually I need is check

Regular expression matching fully qualified class names

£可爱£侵袭症+ 提交于 2019-11-26 12:40:11
问题 What is the best way to match fully qualified Java class name in a text? Examples: java.lang.Reflect , java.util.ArrayList , org.hibernate.Hibernate . 回答1: A Java fully qualified class name (lets say "N") has the structure N.N.N.N The "N" part must be a Java identifier. Java identifiers cannot start with a number, but after the initial character they may use any combination of letters and digits, underscores or dollar signs: ([a-zA-Z_$][a-zA-Z\d_$]*\.)*[a-zA-Z_$][a-zA-Z\d_$]* ----------------

Is there a regex flavor that allows me to count the number of repetitions matched by the * and + operators?

倖福魔咒の 提交于 2019-11-26 08:37:31
问题 Is there a regex flavor that allows me to count the number of repetitions matched by the * and + operators? I\'d specifically like to know if it\'s possible under the .NET Platform. 回答1: You're fortunate because in fact .NET regex does this (which I think is quite unique). Essentially in every Match , each Group stores every Captures that was made. So you can count how many times a repeatable pattern matched an input by: Making it a capturing group Counting how many captures were made by that

How do I do a fuzzy match of company names in MYSQL with PHP for auto-complete?

纵然是瞬间 提交于 2019-11-26 03:27:58
问题 My users will import through cut and paste a large string that will contain company names. I have an existing and growing MYSQL database of companies names, each with a unique company_id. I want to be able to parse through the string and assign to each of the user-inputed company names a fuzzy match. Right now, just doing a straight-up string match, is also slow. ** Will Soundex indexing be faster? How can I give the user some options as they are typing? ** For example, someone writes:

Matching numbers with regular expressions — only digits and commas

限于喜欢 提交于 2019-11-25 23:17:36
问题 I can\'t figure out how to construct a regex for the example values: 123,456,789 -12,34 1234 -8 Could you help me? 回答1: If you only want to allow digits and commas, ^[-,0-9]+$ is your regex. If you also want to allow spaces, use ^[-,0-9 ]+$ . However, if you want to allow proper numbers, better go with something like this: ^([-+] ?)?[0-9]+(,[0-9]+)?$ or simply use .net's number parser (for the various NumberStyles, see MSDN): try { double.Parse(yourString, NumberStyle.Number); } catch