regex

Select a character if some character from a list is before the character

◇◆丶佛笑我妖孽 提交于 2021-02-17 05:43:52
问题 I have this regular expression: /([a-záäéěíýóôöúüůĺľŕřčšťžňď])-$\s*/gmi This regex selects č- from my text: sme! a Želiezovce 2015: Spoloíč- ne pre Európu. Oslávili aj 940. But I want to select only - (without č ) (if some character from the list [a-záäéěíýóôöúüůĺľŕřčšťžňď] is before the - ). 回答1: In other languages you would use a lookbehind /(?<=[a-záäéěíýóôöúüůĺľŕřčšťžňď])-$\s*/gmi This matches -$\s* only if it's preceded by one of the characters in the list. However, Javascript doesn't

gsub with “|” character in R

妖精的绣舞 提交于 2021-02-17 05:43:05
问题 I have a data frame with strings under a variable with the | character. What I want is to remove anything downstream of the | character. For example, considering the string heat-shock protein hsp70, putative | location=Ld28_v01s1:1091329-1093293(-) | length=654 | sequence_SO=chromosome | SO=protein_coding I wish to have only: heat-shock protein hsp70, putative Do I need any escape character for the | character? If I do: a <- c("foo_5", "bar_7") gsub("*_.", "", a) I get: [1] "foo" "bar" i.e. I

String matches regexp [closed]

有些话、适合烂在心里 提交于 2021-02-17 05:39:07
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 9 years ago . I used perl, unix and java regular expression lot of time, but I'm surprised in java about that: "help".matches("^h") is false!! From java documentation: http://docs.oracle.com/javase/8/docs/api/java/lang/String

Regex replace commas within parentheses C#

旧巷老猫 提交于 2021-02-17 05:09:10
问题 I'm having a hell of a time replacing commas only within parentheses for this string: select distinct \n(''+rtrim(ent.custno)+' - '+rtrim(ent.company)+'') as customer, ent.phone, 0 as curr,\n\n(select SUM(billmast.balance) as balance from billmast where billmast.billid = ent.entid and ent.cid = 'abis' and billmast.balance<>0 and billmast.invdate>dateadd(day,-60, getdate()) and billmast.invdate0 and billmast.invdate>dateadd(day,-90, getdate()) and billmast.invdate0 and billmast.invdate>dateadd

Regex replace commas within parentheses C#

丶灬走出姿态 提交于 2021-02-17 05:08:13
问题 I'm having a hell of a time replacing commas only within parentheses for this string: select distinct \n(''+rtrim(ent.custno)+' - '+rtrim(ent.company)+'') as customer, ent.phone, 0 as curr,\n\n(select SUM(billmast.balance) as balance from billmast where billmast.billid = ent.entid and ent.cid = 'abis' and billmast.balance<>0 and billmast.invdate>dateadd(day,-60, getdate()) and billmast.invdate0 and billmast.invdate>dateadd(day,-90, getdate()) and billmast.invdate0 and billmast.invdate>dateadd

Regex replace commas within parentheses C#

本小妞迷上赌 提交于 2021-02-17 05:08:07
问题 I'm having a hell of a time replacing commas only within parentheses for this string: select distinct \n(''+rtrim(ent.custno)+' - '+rtrim(ent.company)+'') as customer, ent.phone, 0 as curr,\n\n(select SUM(billmast.balance) as balance from billmast where billmast.billid = ent.entid and ent.cid = 'abis' and billmast.balance<>0 and billmast.invdate>dateadd(day,-60, getdate()) and billmast.invdate0 and billmast.invdate>dateadd(day,-90, getdate()) and billmast.invdate0 and billmast.invdate>dateadd

How to extract exact matches with list from a dataframe column?

99封情书 提交于 2021-02-17 05:07:02
问题 I have a large dataframe with text that I want to use to find matches from a list of words (around 1k words in there). I have managed to get the absence/presence of the word from the list in the dataframe, but it is also important to me to know which word matched. Sometimes there is exact match with more than one word from the list, I would like to have them all. I tried to use the code below, but it gives me partial matches - syllables instead of full words. #this is a code to recreate the

How to extract exact matches with list from a dataframe column?

自作多情 提交于 2021-02-17 05:06:51
问题 I have a large dataframe with text that I want to use to find matches from a list of words (around 1k words in there). I have managed to get the absence/presence of the word from the list in the dataframe, but it is also important to me to know which word matched. Sometimes there is exact match with more than one word from the list, I would like to have them all. I tried to use the code below, but it gives me partial matches - syllables instead of full words. #this is a code to recreate the

How to extract exact matches with list from a dataframe column?

偶尔善良 提交于 2021-02-17 05:06:19
问题 I have a large dataframe with text that I want to use to find matches from a list of words (around 1k words in there). I have managed to get the absence/presence of the word from the list in the dataframe, but it is also important to me to know which word matched. Sometimes there is exact match with more than one word from the list, I would like to have them all. I tried to use the code below, but it gives me partial matches - syllables instead of full words. #this is a code to recreate the

Java regex throws java.util.regex.PatternSyntaxException: Illegal/unsupported escape sequence for the letter g

徘徊边缘 提交于 2021-02-17 05:01:11
问题 I need to see if a whole word exists in a string. This is how I try to do it: if(text.matches(".*\\" + word + "\\b.*")) // do something It's running for most words, but words that start with a g cause an error: Exception in thread "main" java.util.regex.PatternSyntaxException: Illegal/unsupported escape sequence near index 3 .*\great life\b.* ^ How can I fix this? 回答1: The \\ thing proceeded by whatever character will be a interpreted as a metacharacter. E.g. ".*\\geza\\b.*" will try to find