regex

Eliminate characters before a pattern in R [duplicate]

瘦欲@ 提交于 2021-01-28 13:38:02
问题 This question already has answers here : Remove everything before period [duplicate] (2 answers) Closed 6 years ago . If I have the following dataframe: Fruits ONE_APPLE TWO_BANANAS THREE_ORANGES FOUR_PINAPPLES Is it possible to delete everything before the underscore, getting as a result: Fruits APPLE BANANAS ORANGES PINAPPLES There may be a pattern matching function but I haven't find the right one. Thanks for your support. 回答1: You could try the below gsub command to remove all the

C# / Regex Pattern works in online testing, but not at runtime

吃可爱长大的小学妹 提交于 2021-01-28 13:37:17
问题 With the following RegEx pattern: (?<comment>(^#{2} [^\r\n]+[\s]+)*)(?:^\[(?:(?<hive>HK(?:LM|[DP]D|C[CUR]|U(SERS|SER|SR|S)))[:])?(?<name>[a-z0-9$][a-z0-9-_]{2,63})\])(?<items>[\S\s]*?)(?=\n{2,}) Parsing the following text: [HKLM:Connection] AuthKey = 0x8a79b42z67fct29b42e07b3fd78nc540 Url = https://dev.somewebsite.com ApiPath = /api/ [HKLM:Settings] AutoMinimizeConsole = no StyleFile = Default PhoneNbrs = [+]?[01]{0,3}[-. ]?[(]?[0-9][0-9][0-9][)]?[-. ]?[0-9][0-9][0-9][-. ]?[0-9][0-9][0-9][0-9

Regular expression, replace whitespaces inside tag

陌路散爱 提交于 2021-01-28 12:38:46
问题 I have an incorrect xml string and I would like to build a correct one <root val="yyy"> <fol der val="attribute 1">myfolder</folder> </root> The problem is the white space inside tag: "fol der". It's possible to replace white spaces inside < > tags(but not inside attributes) using regular expression in java? Thanks to all 回答1: If your XML is like this: <root val="yyy"> <fo l der val="attribute 1">myfol d er</folder> </root> Following should work: final Pattern p = Pattern.compile("(?s)(?<=<).

Regex for splitting a phone number

点点圈 提交于 2021-01-28 12:37:22
问题 I'm trying to solve a problem as described below: Given a phone number, split it into country code, local area code and number. The number format is - [Country code]-[Local Area Code]-[Number] Country code consists of 1-3 digits, local area code consists of 1-3 digits and the number is 4-10 digits long (total 12 digits always). The separator between the 3 parts can be either a '-'(hyphen) or a ' '(space). Example: Given Number = 1-425-9854706 Result --> Group 1 = 1 --> Country Code Group 2 =

Regex for splitting a phone number

拜拜、爱过 提交于 2021-01-28 12:30:36
问题 I'm trying to solve a problem as described below: Given a phone number, split it into country code, local area code and number. The number format is - [Country code]-[Local Area Code]-[Number] Country code consists of 1-3 digits, local area code consists of 1-3 digits and the number is 4-10 digits long (total 12 digits always). The separator between the 3 parts can be either a '-'(hyphen) or a ' '(space). Example: Given Number = 1-425-9854706 Result --> Group 1 = 1 --> Country Code Group 2 =

Why does mod_rewrite redirect to /index.php/index.php/index.php etc

人盡茶涼 提交于 2021-01-28 12:27:57
问题 I want every subdomain to act as a folder, so basicly: projects.dev -> / test.projects.dev -> /test amazing-project.projects.dev -> /amazing-project And I have this code in my Virtualhost file: <VirtualHost *:80> ServerName projects.dev DocumentRoot "D:/xampp/htdocs/projects" ServerAlias *.projects.dev RewriteEngine on RewriteCond %{HTTP_HOST} ^(.*)\.projects\.dev RewriteRule ^/(.*)$ "D:/xampp/htdocs/projects/%1/$1" [L,R=301] </VirtualHost> However when i go to "designs.projects.dev" it gets

Partial String Match in R using the %in% operator?

和自甴很熟 提交于 2021-01-28 12:20:15
问题 I'm curious to know if it is possible to do partial string matches using the %in% operator in R. I know that there are many ways to use stringr, etc. to find partial string matches, but my current code works easier using the %in% operator. For instance, imagine this vector: x <- c("Withdrawn", "withdrawn", "5-Withdrawn", "2-WITHDRAWN", "withdrawnn") I want each of these to be TRUE because the string contains "Withdrawn", but only the first is TRUE: x %in% c("Withdrawn") [1] TRUE FALSE FALSE

Is it possible to use sed to replace dependencies's version in a pom file?

旧时模样 提交于 2021-01-28 12:12:42
问题 I have a pom.xml file and I want to replace the version inside any of the dependency nodes from 0.1-SNAPSHOT to a different version (let's say NEW-VERSION ), the only restriction I have is that the replacement should be done only if the groupId matches a particular text, lets say: com.company.xyz . That being said, let's say this is the dependencies section of my pom.xml : <dependencies> <dependency> <groupId>com.company.xyz</groupId> <artifactId>xyz-xx-utils</artifactId> <version>0.1

Regex split a string

梦想与她 提交于 2021-01-28 12:11:38
问题 I am at my wit ends (being a regex novice). I need to split a string like this "abc","","av,as","hello world","nice,name" into 'abc' '\blank\' 'av,as' 'hello world' 'nice,name' Using c# or excel vbs, can someone help with the regex expression? 回答1: Fairly straightforward: "(\\.|[^"\\])*" will work as shown: It will allow escaped quotes and possible whitespace between quotations, and is POSIX compliant, should you ever need that! EDIT I should probably note that it will basically NOT be

Remove duplicate line only contain specific string

只谈情不闲聊 提交于 2021-01-28 12:10:57
问题 I try to remove duplicates lines only if contain a specific string. It's easy to remove only duplicates lines, but some useful lines is deleted with : awk '!seen[$0]++' or perl -ne 'print unless $seen{$_}++' Exemple : keep first occurence of lines containing "host_name=" keep all occurrences of lines containing "plugin output=" with above awk or Perl commands that delete the client number too. My output command : host_name=Client1 plugin_output=Name : Client1 Marseille host_name=Client1