regex

How can I replace multiple words “globally” using regexp_replace in Oracle?

一曲冷凌霜 提交于 2021-02-10 16:02:30
问题 I need to replace multiple words such as (dog|cat|bird) with nothing in a string where there may be multiple consecutive occurrences of a word. The actual code is to remove salutations and suffixes from a name. Unfortunately the garbage data I get sometimes contains "SNERD JR JR." I was able to create a regular expression pattern that accomplishes my goal but only for the first occurrence. I implemented a stupid hack to get rid of the second occurrence, but I believe there has to be a better

R: Use Regex to Import Specific Sheets from Multiple Excel Files

笑着哭i 提交于 2021-02-10 15:57:02
问题 I have a group of Excel files with multiple sheets which don’t follow a standard naming convention. I want to create a single data frame from specific sheets containing the keyword 'frame' . library(tidyverse) library(openxlsx) # Sample Excel File 1 df1 <- data.frame(replicate(10,sample(0:1,10,rep=TRUE))) data_frame2 <- data.frame(replicate(10,sample(0:1,10,rep=TRUE))) list_of_datasets1 <- list("df" = df1, "date_frame" = data_frame2) write.xlsx(list_of_datasets1, file = "writeXLSX1.xlsx") #

htaccess - how to apply RegEx patterns on the output of another - encapsulation

无人久伴 提交于 2021-02-10 15:44:24
问题 I'm performing several regular expressions on a string inside a variable in order to clean it up for further use in the htaccess rules, but it seems rather cumbersome to do such simple thing in several lines: RewriteCond %{THE_REQUEST} (?<=\s)(.*?)(?=\s) RewriteRule ^(.*)$ - [E=HREFPATH:%1] RewriteCond %{ENV:HREFPATH} (^.*)?\? RewriteRule ^(.*)$ - [E=HREFPATH:%1] RewriteCond %{ENV:HREFPATH} /(.*) RewriteRule ^(.*)$ - [E=HREFPATH:%1] RewriteCond %{ENV:HREFPATH} (.*)/$ RewriteRule ^(.*)$ - [E

regex setting max number of letters in first name and last name

别说谁变了你拦得住时间么 提交于 2021-02-10 15:35:54
问题 In a form I ask the user to insert his/her First name and Last name with only a space between them, and no space before and after them. I found the following code: ^[a-zA-Z]+ [a-zA-Z]+$ But I would wish to put restrictions 15 letters max in first , and 20 letters max in last name . 回答1: Use a limiting quantifier: ^[a-zA-Z]{1,15} [a-zA-Z]{1,20}$ ^^^^^ ^^^^^^ The {1,15} limiting quantifier tells the engine to match 1 to 15 characters matched with the subpattern that is located immediately to

regex setting max number of letters in first name and last name

流过昼夜 提交于 2021-02-10 15:35:22
问题 In a form I ask the user to insert his/her First name and Last name with only a space between them, and no space before and after them. I found the following code: ^[a-zA-Z]+ [a-zA-Z]+$ But I would wish to put restrictions 15 letters max in first , and 20 letters max in last name . 回答1: Use a limiting quantifier: ^[a-zA-Z]{1,15} [a-zA-Z]{1,20}$ ^^^^^ ^^^^^^ The {1,15} limiting quantifier tells the engine to match 1 to 15 characters matched with the subpattern that is located immediately to

Linux recursively replace periods for all directorys and all but last period for files with underscores

匆匆过客 提交于 2021-02-10 15:13:57
问题 I have the following command which recursively renames all the files/directory's to lowercase and replaces spaces with _. find . -iname "*" | rename 'y/A-Z/a-z/; s/ /_/g;' How do I extend it to remove all periods from directories and leave just the last period for files? So input would be: this.is.a.directory this.is.a.file.txt Output this_is_a_directory this_is_a_file.txt 回答1: You can do this using find in a while loop and using a regex to leave last DOT for files: while IFS= read -rd ''

Split Multiline CLOB Column - Oracle PL/SQL

喜夏-厌秋 提交于 2021-02-10 15:05:04
问题 I have a table which includes a CLOB field with values consisting of lines of comma-separated values. In the output I want a row for each these lines which start with a particular value. I also want to extract some of the comma-separated values performantly. Input table (3 rows): id my_clob 001 500,aaa,bbb 500,ccc,ddd 480,1,2,bad 500,eee,fff 002 777,0,0,bad 003 500,yyy,zzz Target output (4 rows): id my_clob line_num line second_val 001 500,aaa,bbb 1 500,aaa,bbb aaa 500,ccc,ddd 480,1,2,bad 500

Regex for Markdown Emphasis

若如初见. 提交于 2021-02-10 14:51:39
问题 I'm trying to match the following markdown text for emphasis: _this should match_ __this shouldn't__ _ neither should this _ _nor this _ this _should match_as well_ __ (double underscore, shouldn't match) The issue that I'm facing with my own efforts as well as other solutions on SO is that they still end up matching the third line: _ neither should this _ Is there a way to check of my particular use case? I'm aiming this for browser applications, and since Firefox and Safari are yet to

RegEx for pin number

徘徊边缘 提交于 2021-02-10 14:48:42
问题 Im looking to create a RegEx for java to validate a Pin Number that needs to be at least exactly 6 character long and not all numbers can be equal. I got /\d{6}/ but I I'm having a little trouble finding out how to make sure all 6 numbers should be different, so 000000 is invalid, while 000001 should be fine. 回答1: You can use this regex with a negative lookahead assertion: ^(\d)(?!\1+$)\d{5}$ RegEx Demo RegEx Details: ^ : Start (\d) : Match and capture first digit in group #1 (?!\1+$) :

Regex to match a word or a dot between words (optionally) in a string

只愿长相守 提交于 2021-02-10 14:40:51
问题 I'm currently working on an issue that matches a word between special characters. Optionally matches words in between dot. I currently tried below regex pattern it works fairly well in words that have dot in between but I struggled to make it work with word without dot. [^\W\s]+\.+[^\s\W)]+ Given the string: ,DECODE(T3.ATEST,' ',T3.BATEST ,DECODE(NVL(T4.BATEST,'9') ,'1',NVL(T4.BATEST,' ') ,T3.BATEST)) it matches the following: T3.ATEST T3.BATEST T4.BATEST T4.BATEST T3.BATEST Now trying this