Questions tagged [regex]

92021 questions
1

votes
1

answer
59

Views

string extraction and dupes filtering mac OS X

I have a bunch of files with sql log. I'm looking out to extract all occurrences of the following pattern SQL log has sql that looks something like this sel * from DB.T1; update DB.T1; delete from DB.T2; collect stats on DB.T3 index (a,b,c); sel count(*) from Db.T1; sel count(*) from db . T2; sel...
pmv
1

votes
2

answer
35

Views

Having trouble with less than(<) operator in php preg_match_all

I'm trying to parse a query string and have run into something I can't quite figure out. Trying to match a string that can contain either < or >, but I'm seeing some weird output only when the string contains a Returns as expected: Array ( [0] => Array ( [0] => wt>f ) [1] => Array ( [0] => wt>f )...
Knut L
1

votes
0

answer
99

Views

How to add regex rules in .ctags file for matching javascript es6 method?

I am using this line for matching methods of javascript file: --regex-javascript=/^[ \t]*([A-Za-z0-9_$]+)\(.*\)[ \t]*{/\1/M,Method,Methods/ But this rule will also match if(), switch() and for(), I changed the rule to --regex-javascript=/^[ \t]*(?!(?:if|for|switch))([A-Za-z0-9_$]+)\(.*\)[ \t]*{/\1/...
LCB
0

votes
2

answer
17

Views

Concatenate related fields and replace within data frame

I'm in the process of concatenating two related fields throughout a large dataset. I feel like I have most of what I need but can't concat the fields properly. dataframe: id| date1foo| time1bar| date2foo| time2bar| date3foo | time3bar --|---------|---------|---------|---------|----------|--------...
grigs
0

votes
1

answer
17

Views

splitting a whitespace separated string, ignoring whitespace within single quotes

My Java input String str = 'aa 2 xx 'b cc dd e' -o se '4-5'' I want to output the tokens delimited by white space, except for the white space within single quotes. So, the output should be: aa 2 xx 'b cc dd e' -o se '4-5' I can do it by splitting the String on whitespace, and then coalescing a seque...
labrat43
1

votes
1

answer
14

Views

Use regex_extract to retrieve the score number in a string text column

I need to extract the float number after score. {'reason_desc': { 'score':'0.1', 'numOfIndicatrix':'0', 'indicatrix':[]}, 'success':true, 'id':'1555039965661065S427A2DCF5787920' } I expect the output of 0.1 or any number enclosed by ''.
JYWQ
0

votes
2

answer
26

Views

How to create a regex that will find a substring of a complex URL

Need some guidance on creating a regex that will identify part of the URL. URL1: test-project-233-TEST-ENDPOINT.test.as.ds.abcdefg.com URL2: test-project-124-ENDPOINT.test.dd.ad.gf.abcdefg.com The goal is to build a regex that can parse out 'test-project-233' and 'test-project-124' for me. I've alre...
Dyl
1

votes
1

answer
85

Views

separate select clause and insert clause from sql string

I am trying to solve spark sql small files problem using the above approach , in my organization users pass in sql statements for example. insert overwrite table x partition (column1) select * from y; I can run the above sql in spark sql problem is it creates small files when compared with hive whic...
1

votes
2

answer
54

Views

How can be returned input register using only array lower case words in jquery textcomplete?

I use jquery textcomplete in my project. Is it possible to return the input register using a word array only in lowercase. I looked in Google Translate the approximate functional and there too the input result does not return at input. There, the search is performed with any word entry register, but...
John
1

votes
2

answer
71

Views

Python re.sub with raw string prefix replacing 10 with H and 20 with P

I'm building some templating into my app that takes a string like this: templateString = r'{title} {- author} ({timestamp})' And replaces the appropriate string (if it exists) inside the template {}: # 10 things on my todo list - Brandon (2018-01-01 00:00:01) I want to allow custom chars inside the...
brandonscript
1

votes
1

answer
41

Views

Find all semicolons surrounded by numbers in MS Office WORD

In a word document, I'd like to find all semicolons that are surrounded by numbers. so I need the Find/Replace DialogBox to find and select ; in 123;4 and 1;234 (but not example;example or not example; example) . Please note that in the example above, I just need the semicolon selected for formattin...
M_M
1

votes
1

answer
112

Views

Regex pattern with [:] returns as invalid

I'm searching a text for a specific pattern using regex and it seems to work fine until I want to include a ':' the function I use to find the text is: func matches(for regex: String, in text: String) -> [String] { do { let regex = try NSRegularExpression(pattern: regex) let results = regex.matches(...
MotoxX
1

votes
2

answer
282

Views

Regular expression with danish phone number

i am trying to write a regular expression so i can replace following phone numbers with a link: first +45 55 44 33 22 second +4555443322 third +45 55443322 fourth 55443322 and last 55 44 33 22 currentley my regular expression looks like this: Regex phoneRegex = new Regex(@'[0-9]{8}', RegexOptions.Ig...
Dakar2008
1

votes
1

answer
653

Views

Search and Replace text between curly brackets (VS Code)

I've been searching for ages how to replace text between brackets in VS Code. Here's an example or a file I want to replace content in: capital = 267 oob = 'AFG_1936' set_technology = { CAS1 = 1 CAS2 = 1 CAS3 = 1 CAS4 = 1 radio_detection = 1 rocket_engines = 1 sp_rocket1 = 1 sp_rocket2 = 1 strategic...
stuffi3000
1

votes
2

answer
79

Views

regex email pattern in a negate way

I was working around some regex pattern I have a variable, var url = '[email protected]'; The url contains emailId. I have a regex pattern to check if the variable contains emailId. var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; My requirement is: I...
user9188964
1

votes
2

answer
162

Views

Python extract information after phrase or group of words

I am trying to extract information from PDF. Simple search worked: filecontent = ReadDoc.getContent('c:\\temp\\pdf_1.pdf') match = re.search('Document ID: (\d+)', filecontent) if match: docid = match.group(1) But when I want to search a long phrase, e.g. I want to extract '$999,999.00', which may ap...
Eyedia
1

votes
1

answer
36

Views

.htaccess regex

I'm a real beginner with regex. I think I NEARLY understand this, but having spent a day and a half on it, I can't quite get it right. At the moment my OLD domain has this rewrite: RewriteRule ^/?$ 'http\:\/\/sheepdog\-training\.com\/' [R=301,L] That successfully redirects every page on the old site...
Andy
1

votes
2

answer
67

Views

exclude an entire word and force a lazy regex behaviour

I would like to have a regexp that matches all groups of words in a text that start from 'a' and end in 'e' with the exception of those that end in the 'the' article. E.g., in the sentence 'And here are the four sleeping guards, smitten from the side by an invincible flood of sunlight' I need to mat...
Svetlana
1

votes
0

answer
121

Views

port exclude pattern from inotifywait to fswatch

So I have this regex exclude pattern which works excellent with inotifywait on Linux: .*\.\w+\.\w{6} Now I want to port it to fswatch on macos and use with -e or -Ee flag. What have I tried so far without any luck: -e '.*\.\w+\.\w{6}' -Ee '.*\.[[:alpha:]]+\.[[:alpha:]]{6}' -e '.*\..+\..{6}' # not ex...
valignatev
1

votes
2

answer
85

Views

pull numbers and letters together python regex

I am looking to delete any text from a string in python that matches something along the lines of '\nPage 10 of 12\n' where 10 and 12 are always different numbers (looping through 300+ documents that all have different page lengths). Example of some text that is in my string below (and then what i w...
eluth
1

votes
0

answer
554

Views

Symfony config | trusted hosts | Correct regex pattern for any subdomain?

I'm working on my first Symfony-based application and I want to use the 'trusted_hosts' option to make my app a little more secure. I started developing by using Symfony's own HTTP server which ran under 'localhost'. But I also have an Apache with correct vHosts setup for www.domain & dev.domain. I...
BuddhaBone
1

votes
1

answer
109

Views

Using variables in re.findall() regex function

I have a list of regex patterns like k[a-z]p[a-z]+a and a list of words that can fit into these patterns. Now, the problem is that, when I use: re.findall(r'k[a-z]p[a-z]+a', list) Everything works properly, but when I replace the raw expression with a variable like: pattern = 'r'' + pattern + '''...
Spike Spiegel
1

votes
0

answer
68

Views

dlopen'd SO's conflict when unloaded

I have two .so files that statically link boost regex. each of those so's are plugins that get dlopen'd by my main executable. It seems that when I unload one of them, it causes out of bound reads in the other so. My theory is that when one so is unloaded, the other one's copy of boost is actually...
mercurytw
1

votes
1

answer
32

Views

Regex: Remove particular repetead-words from tags in several html pages

I have this text with many   under the tag An Extension of Java for Event Correlation. 571 geographical/logical coordinates, or sources. Henceforth, we will use the term events to refer to both the incidents underlying such events as well as to their incarnations and notifications I want to...
Rob Rob
1

votes
3

answer
124

Views

Check empty lines in Python

I have a text file which contains multiple number of lines. I want to check a specific line (calling xyz ...) in present or not in between two line(++ start line and -- exiting line). If the line (calling xyz ...) is present then it should return the line and if line is not present then NULL value s...
1

votes
2

answer
59

Views

Split AMEX Transaction detail strings using regex

I have an array of transaction description strings from an American Express Card that I will be using PHP's preg_split() to parse; [ 'THE DISNEY STORE #90DANBURY CT', 'CHRISTMAS TREE SHOPSDANBURY CT', 'BATH & BODY WORKS 07DANBURY CT', 'CITGO DODGINGTOWN GANEWTOWN...
Mark Carpenter Jr
1

votes
0

answer
260

Views

Regex with new line character is matching string

I've got a regex expression in a Mongo Meteor query: Programs.find({ Notes: { $regex: '^((?!REFUNDED).)*$' }}).fetch() This should read, 'Return all documents where the 'Notes' field (a string field) doesn't contain the string 'REFUNDED''. I'm finding a problem when the text in the Notes field cont...
flimflam57
1

votes
1

answer
27

Views

How to use regular expression to modify a text file in r and obtain the desired file?

I have dataframe like this: Patient_ID=c(10001,10002,10002,10003,10001,10004,10005,10005,10006,10006) Diagnosis_Codes=c(1,16,5,55,28,1,1,12,14,83) Diag_Index= c(1,2,3,4,5,6,7,8,9,10) df=data.frame(Patient_ID,Diag_Index,Diagnosis_Codes) df I used the following code to have wide-format data: library(r...
Nima Caiser
1

votes
2

answer
491

Views

Angular regex error

I'm creating a form in Angular that requires the rate field to take only numbers with 2 decimal places. My HTML is as follows: On every keypress event I'm calling _keyPress() method as follows: _keyPress(event: any) { const pattern = /[0-9\+\.\ ]/; let inputChar = String.fromCharCode(event.charCode)...
Dipin raman
1

votes
1

answer
65

Views

How to use user input value as part of regular expression for other field validation in AngularJS

I have 2 fields with their respective ng-model fields. I want to use 1st field value in 2nd field's ng-pattern expression. E.g. EmployeeID and EmployeeFile fields. EmployeeID is mapped to $scope.empId. EmployeeFile is mapped to $scope.file. For validating file input, the pattern should be like ^.{...
1

votes
2

answer
62

Views

Java takes excessively long to determine whether a string matches with String.matches

I have the following regular expression which matches any characters at the beginning ending with text in parenthesis 'Hi (Stackoverflow)'. When I enter this text to be matched, the program just keeps running. String pattern = '^[a-zA-Z]+([\\s]*[\\w]*)*\\([\\w]+\\)' String text = 'Asdadasdasd sadsds...
Luke
1

votes
1

answer
38

Views

Regex - aways separate operands with operators

I would like to validate my infix notation through regex. Right now I have something like this: ^[a-zA-Z0-9_]+(( [a-zA-Z0-9_]+)|( [\+\-\/\*]))*( [a-zA-Z0-9_]+)$ I check if the expresion starts and ends with operands. In the middle i can have operands or operators always devided by single space. Ther...
androlama
1

votes
3

answer
41

Views

Issue with searching for strings in text in Powershell

I am building a script to monitor backups with Ahsay in PowerShell and have run into an issue with identifying backup types, it works by checking for certain keywords in the first few lines of the log file, and I want to have it so that if it contains the word 'File List' but also contains the word...
Tom Halverson
1

votes
1

answer
93

Views

Text file to JSON, last few lines are not included in the result

I'm reading a text file and converting it to JSON format using regex in my react project.It is working fine but not including last 20-30 lines of the text file. There is some problem while converting it to JSON but I am unable to understand the problem. Here is my code: readTextFile = file => { let...
Srajan Rastogi
1

votes
1

answer
160

Views

LogStash Grok regex backreferences

I'm really hoping I'm doing something silly and just can't see the problem... this would be trivial in Perl or other languages. Apparently backreferences are supported in grok https://grokconstructor.appspot.com/RegularExpressionSyntax.txt, but I can't make them work. I need to match on something...
Aaron
1

votes
2

answer
292

Views

.htaccess add Custom Header to File directive matching pattern

I have on my website many pdf's that ends with a digit although they are the same pdf. I want to add a Canonical Link via .htaccess (using Files or FilesMatch) to the pdf's that ends with a digit to the corresponding pdf I think the pattern needs to be {anything}-{digit}.pdf Ex: Header add Link '; r...
AdrianD
1

votes
3

answer
58

Views

How to use regex to restrict numeric?

Code below will accept only numeric on keypress. How can I restrict it by range. I want to accept only 12 char. const checkNumber = e => { const x = /[0-9]+/g; if (!x.test(e.key)) { e.preventDefault(); } }; checkNumber(e)} /> Changing to const x = /[0-9]{12,12}+/g; does not worked. No maxLength plea...
sg552
1

votes
1

answer
319

Views

v # invalid expression\nsre_constants.error: bad character range , Ansible

I am using Ansible to write a content to a file which looks like : [localhost] localhost [es-master] [es-data] [es-client] The play is : - name: Debug the variable name debug: msg={{ ec2_details | type_debug }} - name: Add Instances to local inventory file local_action: lineinfile path='~/ansible-e...
1

votes
1

answer
40

Views

Splitting a single column in r into 4 separate columns

I am in need of splitting a single data frame column (ID) into five separate columns (A, B, C, D, E). The columns need to be split by: A - First Letter B - All numbers until the second letter C - All letters until the last letter D - Last number E - Last letter Heres an example: Before ID Conc 1 A...
Jake Bernards
1

votes
0

answer
137

Views

Regex expression for IP exclude Network and broadcast address in Javascript

Hi I have to write a regex which validates all the IPs except the Network and broadcast address. For eg: I want only the ips which are not like xxx.xxx.xxx.0 or xxx.xxx.xxx.255 (((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-4]|2[0-4][0-9]|[01]?[0-9][0-9]?))(?![\\d])([,\s]+|$))* This is...
Varun Sharma

View additional questions