Questions tagged [regex]

Regular expressions provide a declarative language to match patterns within strings. They are commonly used for string validation, parsing, and transformation. Since regular expressions are not fully standardized, all questions with this tag should also include a tag specifying the applicable programming language or tool. NOTE: Asking for HTML, JSON, etc. regexes tends to be met with negative reactions. If there is a parser for it, use that instead.

2
votes
0answers
6 views

Trying to validate date entry with javascript regex as the user types

I'm trying to update an older app with some date validation as the user types it in a text field. I have a bare bones demo here http://jsfiddle.net/7d82j0ky/2/ where if you enter the following dates: ...
0
votes
1answer
26 views

Trying to matchAll a regex on a JavaScript string

I'm trying to string.matchAll the following string: const text = 'textA [aaa](bbb) textB [ccc](ddd) textC' I want to match the following: 1st: "textA [aaa](bbb)" 2nd: " textB [ccc](ddd)" 3rd: " ...
0
votes
0answers
11 views

How to capture strings until a certain token appears using regex? [duplicate]

I am trying to use regex to look through a report and capture from the beginning until one of a set of tokens appears. I tried this (.|\n)*(?=token1|token2|token3), and my assumption was that it would ...
-2
votes
2answers
16 views

Regex search for Edge version in Javascript

I want to figure out if a user is using Microsoft Edge, and if so, what version of Edge it is. I know I can get the version using navigator.userAgent, and in my own Edge browser that returns Mozilla/...
0
votes
0answers
20 views

Swift 5: Using keyword to split a string into an array of strings [duplicate]

I have strings that describe competitions, i.e. "Person A vs. Person B vs. Person C". I want to automatically extract the individual participants and return them as an array of strings, i.e. [Person A,...
1
vote
4answers
31 views

How to replace any brackets for rounded brackets?

Here is code: $string="{1},[2],(3),<4>"; // Replaces closing square, curly, angle brackets with round brackets $string = preg_replace('/\{\[\</', '(', $string); $string = preg_replace('/\}\]\...
0
votes
0answers
17 views

How to use Calculated Join in Tableau using 1-M relationship and regex_extract

I'm attempting to join two data sources in Tableau using a regex in a calculated join because the left table has 1 value in each cell (ie. 64826) and the right table has 0-4 possible matches in each ...
0
votes
0answers
14 views

Regex match only from a list of words in any order [duplicate]

I have a list of names that I want to match within a string. The names can be arranged in any order, and a precondition for that string is no duplicates. I need the match to be exact, failing if there ...
0
votes
1answer
18 views

PHP find youtube url to embed _match and _replace

Can not figure out why this code doesn't work. It's taking text file content, replacing the youtube url (in text only) with the embed but I get no response. $yt_pre = "/https?:\/\/(?:www)?\.youtu(?:...
-2
votes
0answers
12 views

How to write “four letter word” in regex referencing an English idiom?

I am writing a blog post and thinking of adding some humor (dunno if it will fly), but basically referencing the typical "taking the s**t our of x" and replacing the four letter word with regex. ...
0
votes
1answer
25 views

Detect XSS with RegEx but ignore HTML commented ones

First of all, I know every platform (NodeJS, ASP.NET, ...) all have XSS filters, I should use ASP.NET filters, I should use security libraries from OWASP, I should not create XSS filter with RegEx... ...
1
vote
1answer
30 views

Parsing with Regex out of text file

I have a text file ; Message Number ; | Time Offset (ms) ; | | Type ; | | | ID (hex) ; | | | | ...
0
votes
0answers
21 views

Using the regex /\[.+\]\(.+\)/ to split a string? [duplicate]

String = "textA [aaa](bbb) textB [ccc](ddd) textC" I'd like to split this string into an array with: array[0] === "textA " array[1] === " textB " array[2] === " textC" I want to use the regexp /\[.+...
-4
votes
1answer
23 views

What is the regex expression to extract 3 letter word starting with M followed by 2 number? [duplicate]

I want to extract first 3 letters of the sentence which start with M and are followed by 2 digits. If sentence is M30 INTHE SKY then output should be M30. IF sentence is THE INTHE SKY then answer ...
-2
votes
3answers
34 views

How to write Custom Regular Expression to validate decimal float number 0.001 to 0.800 only? [on hold]

I am creating a form input field where user are allowed to input decimal number range 0.001 to 0.8 (or 0.800) only. I could not find a way with how to write custom regular expression? Kindly help me ...
-3
votes
0answers
12 views

What is the simplest way to reverse order in Emeditor?

What is the simplest way to reverse order in Emeditor? Example: 01,09,65,80 -> 80,65,09,01 65,11,76,32 -> 32,76,11,65
0
votes
1answer
45 views

Java: Searching an elegant way to split String

I know there are a lot questions and answers to regex related topics and I already read a lot of them and tried several ways myself but they all do not seem to be easy to understand. So I wanted to ...
-1
votes
2answers
36 views

Regex and replace function to convert link text pattern to <a> tag [duplicate]

I'm willing to parse some text and add an <a> tag based on the following pattern (the some one that it's used here on StackOverflow textareas): [link description](http://somewebsite.com) The ...
0
votes
0answers
27 views

awk unable to escape forward slash

i am getting out certain matched column using awk, but when i am giving variable as "Lag 1:1008:3622" it is working as expected but when i given variable "Port 1/1/3.101" it gives me error (^ ...
-2
votes
1answer
21 views

Perl - truncate where values overlap and concatenate

I am new to the Perl language and am trying to convert some data from a MYSQL database. I'm working on pulling addresses from two different tables, and my goal is to concatenate a "complete" address. ...
2
votes
2answers
23 views

Extract hive count string using regex

I am trying to get total number of records in a hive table using paramiko. I know we can use Pyhive or pyhs2 but it requires certain configuration and it will take alot of time to get that done from ...
-3
votes
0answers
23 views

Create a regex to verify specific string format [on hold]

I'm trying to create a regex to verify these string formats: [EVERY DAY] [DAY : 1] or [DAY : 2] or ... or [DAY : 31] [EVERY MONDAY] or [EVERY TUESDAY] or ... or [EVERY SUNDAY] [DAY : 5 ; DAY : 22 ; ...
0
votes
0answers
24 views

RegEx from Automate the Boring with Python [duplicate]

I have the "Automate the Boring Stuff with Python" book by Al Sweigart and have been working through the book the last week and I'm currently on Chapter 7 on regular expressions. I'm trying to do the ...
0
votes
1answer
20 views

Match words and sentences between HTML tags while ignoring whitespaces at the beginning and the end

I'm trying to write a simple regex to select texts inside HTML tags inside of my editor (VSCode). The following regex almost achieved that, except that it selects words only and not sentences, for ...
-1
votes
0answers
24 views

How to find regex pattern of a column (dynamic) in dataframe ? column being a primary key in a database table

I need to find regex pattern of column for any give dataframe. Only one help is that the column is a primary key in the table. If the column is numerical it is easy, but if its a string then I was ...
-4
votes
1answer
29 views

What is the Regex ? every unicode characters (but not every blank ones except the spaces)

I am basically trying to find a Regex against which you could test a Nickname/Pseudo after a form validation. For exemple I want this to be allowed: "ཀུ༇ༀ" or this 0X-_my perfect name_-X0" but not ...
1
vote
1answer
31 views

How to get substring based on a character and starting to read the string from the right

I have the following values on a column: DB3-0800-VRET, DB3-0800-IC, IB-TZ-850-IB, O11FS-OB ... From each value I want to remove the last part after the dash. I need to have the following result: ...
1
vote
3answers
49 views

How do I replace an image URL with an image tag in a JSON object?

This is the JSON response I'm getting from the server: const response = { status: "OK", data: { qr_code_string: "/ AFFFFABRRRQAUUUUAFFFFAB", image_url: "http://s3.amazonaws.com/...
0
votes
0answers
32 views

Highlight characters in string using different colors php

I'm trying to highlight separate characters (letters), in a string using 4 different colors. What I would like is.. Key: ,Y,2 = Red background/white text ,Y,1 = Red background/white text ,T, = ...
0
votes
1answer
17 views

RegEx: How to apply a Character Set restriction to a whole Expression

Let's say I have a regex which is used to validate email addresses, such as: /^(([^<>()\[\]\\.,;:\[email protected]"]+(\.[^<>()\[\]\\.,;:\[email protected]"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,...
-1
votes
0answers
51 views

method always returning false, where am I making mistake in patterns [duplicate]

I should validate one of the user field name it has "knowledge" knowledge field should be in the format has show below: "knwl1" knwl1 is knowldge1! "knw12" knwl2 is knowledge3! "abcx" there is ...
-1
votes
1answer
22 views

Get error result when search match for only one time

I wanted to search a string that matched exact times in another string, while I met some problem. use strict; use warnings; my $test="abc1234abc5678abcdef910"; my $cut_seq="abc"; print $test,"\tone ...
2
votes
4answers
44 views

How to сreate a regular expression for the dollar currency?

I want to create a regular expression for the dollar currency. This examples should be find by regex: $ 10 10$ 10 $ 1000005 dollars And don't work on this: dollars one million and five I have ...
0
votes
2answers
46 views

Use of $ symbol instead of %

I have started practising SQL and I think I need to brush up some topics. This problem statement in hackerrank states that the query lists CITY names from STATION that do not end with vowels. I ...
0
votes
0answers
17 views

TypeError: 're.Pattern' object is not callable [duplicate]

I am trying to make a program in which i enter a link then validate if the link is of A SPECIFIED PATERN IN THIS CASE IT IS- https://link.brawlstars.com/invite/gameroom/en?tag= and at last i want the ...
1
vote
1answer
28 views

Regex for Windows “Message” from syslog source

I have Windows logs being aggregated to a syslog server which is messing with the format a little bit and I'm trying to work a regular expression (PCRE) to be reformat it a little so I can extract ...
0
votes
2answers
41 views

How to convert dots to commas decimal notations using excel formula

Let's say the user enters 1.234.567,89 or 1,234,567.89 or 1 234 567,89 in any excel cell one by one and in all the above cases the user should get 1234567,89 in the output cell.
-1
votes
0answers
21 views

Exclude some word regular expression in java [duplicate]

I met difficult regex in java. I want to search only catch contexts. But searched in // CASE 1 and break; } syntax. This is Regex101 site for this problem. https://regex101.com/r/VXlYCh/1/
-1
votes
2answers
32 views

How to generate a regex with Max of 3 numeric chars before & after the “/” where Numbers before the “/” should be greater than numbers after the “/”

I have to generate a regex with following conditions Max of 3 numeric chars before and after the "/" Max of 7 chars including "/" and no other special chars & decimals allowed Numbers before ...
1
vote
1answer
33 views

Need to extract certain data from paragraph listed in Google sheet cells

I import data from a bot at my work this data is stored like Time: 6/17/2019 Users: Tom, Gerry, Lisa Cover: 150 Actually, developers here are lazy to give me the data in a proper way so I have to ...
-1
votes
2answers
24 views

Writing regex pattern with multiple conditions

I want to find urls in a html content String in Java. This urls should have some conditions. As an Example consider below String. "background-image: url("https://mmbiz.qpic.cn/mmbiz_gif/...
4
votes
1answer
100 views

Extract Windows file path, file name and file extension via single regex

I have a full file names (in Windows, include network paths). Test strings: 01: @"\\.ext", 02: @"\\filename", 03: @"\\filename.ext", 04: @"\\file.name.ext", 05: @"\\path\path\.ext", 06: @"\\...
1
vote
1answer
25 views

Find emojis in a tweet as whole clusters and not as individual chars

So first question I've ever asked on here, and its about emojis. I'm sorry. I am making a twitter bot in python with the help of Tweepy, and regex ( also tried python-pcre ) that will analyse a tweet ...
0
votes
0answers
31 views

Determine whether a string is a WKT

I have a csv of values, and I need to determine if a string-field is a well-known-text geometry representation. For example, if I have the following data: name,info "tom","POINT (30 10)" "brad","...
1
vote
4answers
49 views

Need a Regex that includes all char after expression

I am trying to figure out a regex. That includes all characters after it but if another patterns occurs it does not overlap This is my current regex [a-zA-Z]{2}\d{1}\s?\w? The pattern is always 2 ...
0
votes
2answers
41 views

How can I convert an integer like “170526” into its equivalent date (in this case 05/26/17)?

In my spreadsheet, I've got a bunch of dates formatted weird like: 170526 180921 181002 181002 181021 I'd like to use a formula and convert those over to: 05/26/17 09/21/18 etc. where the first ...
3
votes
2answers
52 views

unexpected result by cutting the last column with sed

echo '60 test' | sed -r 's/(.*)\s+[^\s]+$/\1/' result: 60 test the last column is not cut. but it works pretty well with echo '60 home' | sed -r 's/(.*)\s+[^\s]+$/\1/' result: 60 why?
1
vote
2answers
39 views

How to match cjk characters with sed?

I'd like to match CJK characters. But the following regex [[:alpha:]]\+ does not work. Does anybody know to match CJK characters? $ echo '程 a b' | sed -e 's/\([[:alpha:]]\+\)/x\1/g' 程 xa xb The ...
0
votes
0answers
21 views

Need a regex that picks up all config files except for one specific case [duplicate]

6G rules block access to config.* files. I need to allow a specific config.js. I tried to construct a REGEX using one of the online testers but didn't have any success. The specific .htaccess rule ...
-1
votes
1answer
46 views

Is it possible to have pandas csv_reader “sep” parameter use space a word and a number?

I'm using pandas (python) csv_reader, and I don't know if it is possible or efficient to have a regex expression on the "sep" parameter that returns the dataframe as I want. I'm reading from a ...