Most voted "regex" questions
Use this tag when the question refers to some resource, information, or problem relating exclusively to regular expressions. Regular expressions (usually abbreviated as "Regex", "regex" or "regexp") are a declarative language used for matching patterns within strings. When asking, also include a tag specifying the programming language or tool you are using to identify one of the different dialects.
Learn more…1,253 questions
Sort by count of
-
5
votes1
answer174
viewsScraping with python
How to capture one or more phrases from a website with Python and/or regular expressions? I want everything that starts with <p>“ e acabe com ”</p> Example:…
-
5
votes3
answers12621
viewsHow to remove specific words with javascript
How can I remove specific page title values? Title: STACKOVERFLOW REMOVE: STACK RESULT: OVERFLOW
-
5
votes1
answer149
viewsWhat is ~ in regular expression for?
I have the code: function addhttp($url){ if(!preg_match('~^(http)s?://~i', $url)){ $url = 'http://'.$url; } return $url; } It adds HTTP if the given URL does not contain, but what I’m doubtful about…
-
5
votes5
answers4008
viewsRegex take from one point to the other within a text
I have the following text:: From: .... blabla bla Message: blablabalab //linha em branco From: .... blabla bla Message: blablabalab //linha em Branco From: .... blabla bla Message: blablabalab How…
-
5
votes2
answers998
viewsRegular expression, taking values from HTML
I have an HTML that I need to remove values from a set of <li>. This is the HTML part: <ul id="minhas-tags"> <li><em>Tagged: </em></li> <li><a…
-
5
votes2
answers189
viewsRegex - Operator "." - Meta character capture
Situation I’m conducting a survey with regex in a specific word inválido, but I decided to use inv.lido. Which I knew I had in the test string but didn’t return. Testing vr = var_dump pr = print_r…
-
5
votes2
answers2657
viewsRegex to pick sequence of equal numbers
I need to do a validation using regex, how do I validate if a string is coming with repeated numbers? for example "1111","2222","3333"
-
5
votes2
answers182
viewspreg_split is not breaking the strings in the array
I’m not getting to use the function preg_split() correctly. I’m trying to break a string array() via regex but it’s not happening. $string = "<:termo.9:><:termo.10:><:termo.11:>";…
-
5
votes1
answer548
views9 Type and Count Lines via Regex Notepad++
First doubt: How to convert a phone book that is in format: 1188888888 1288888888 3188888888 1187877766 for: 11988888888 12988888888 31988888888 11987877766 via Notepad++ regular expression? Or…
-
5
votes3
answers296
viewsFunction that converts this string to a json
I have a string in the following format: "a=123 b="ABC" c="Olá Mundo!"" need to create a function that transforms this string in this json: { a : 123, b : "ABC", c : "Olá Mundo!" } I think it has a…
-
5
votes1
answer2067
viewsHow to extract text in parentheses with regex in php
I have the text: Regular expressions (often abbreviated to "regex") are a declarative language used for correspondence. How do I get the content included in the parentheses? I tried to: $texto = "As…
-
5
votes4
answers11013
viewsValidate phone number with optional ninth digit
How to validate phone number with the optional ninth digit? in the following formats: DDD + 8 digits = (21) 9876-5432 DDD + 9 digits = (21) 98765-4321
-
5
votes3
answers212
viewsCapture the WHERE clause of an SQL query
I need to capture only the clause where several queries to analyze the filters used. For example: select "DIM_1"."col1", "DIM_2"."col2" , "DIM_3"."col3" , "DIM_4"."col4" , "FAT_1"."col5" from…
-
5
votes1
answer68
viewsCapture the index data in the database
I was able to feed my listview with Sqlite data, however, I now want to capture the data (in the database) that each line of listview matches. For example: Line 10 displays Code. 1 and Name: Felipe…
-
5
votes2
answers559
viewsRegular Expression for password
I’m trying to do a strong javascript password check. Initially I want to check if in the string there is the occurrence of 02 numbers in the following conditions: "12vvv": two consecutive numbers or…
-
5
votes2
answers972
viewsRegular expression with specific ending bring 3 first characters
I am trying to make a regular expression on Oracle with the following requirement: End with a specific letter if you have this letter in the middle not searching. Return the first 3 digits of the…
-
5
votes3
answers370
viewsSort phone numbers in a string
I have some phone numbers, mobile and fixed, in a database, I used the function implode()to join them together in the same string, getting that way: (11) 3333-4353 (11) 98000-2222 (11) 3027-5555…
-
5
votes1
answer141
viewsPerl: Find a line in a txt by matching typed words?
Good afternoon, I have a notepad with several lines typed as for example: ★ Bayonet ★ Bayonet | Autotronic (Battle-Scarred) ★ Bayonet | Blue Steel (Minimal Wear) ★ Bayonet | Case Hardened…
-
5
votes7
answers5040
viewsRegular expression for accepting numbers and letters, regardless of sequence
I have the following problem, I need to validate a password field with at least 8 characters, being at least 2 numbers and the rest letters, they can be in any position. 12abcdef abcdef12 The…
-
5
votes1
answer167
viewsLocate line that starts with negation of the expression
I have a text file with many lines. It is possible for me to find the first line that does not match the regex? Example, I want to make a regex that shows me the first line that doesn’t start with…
-
5
votes2
answers697
viewsRegular expression supporting at least two of the four conditions
I am writing a regular expression for password validation. I wanted to know the easiest way to get a regular expression to accept, at the very least, two of these conditions: Capital letters…
-
5
votes2
answers326
viewsRegular Expression R
I have a variable that indicates the year of Elementary School that a student is attending, but this variable was not fulfilled in a single way. For example the 1st Year of Elementary School because…
-
5
votes2
answers127
viewsReplaceall() does not remove "|"
I have a following string "|" and I would like to replace it with a simple "", my java code is like this: String teste = "|A|B|C"; teste.replaceAll("|",""); Exit: "|A|B|C" I would like the output to…
-
5
votes2
answers487
viewsString Sweep in Search of Substrings Ignoring Accent and Case and For Each Match Perform an Action
I need to search in a string a specific substring and for each occurrence found, I must execute an action to replace what was written by the version in bold, as it appears in the list, ignoring…
-
5
votes4
answers169
viewsWhich way can I use regular expression to capture just a few link attributes
I need a basic example(s) of how I can make a tiny script to pick up only the contents of(s) attribute href. I’ll simplify the explanation into two groups, it’s them: To and B In the Group A we have…
-
5
votes1
answer138
viewsHow to detect if a string is a regex
Supposing I have the string: $regex = "/[^a-z_\-0-9]/i"; There is something native to php to test if it is a regex validate? If not, what would be the best way to test it ?…
-
5
votes2
answers334
viewsWhy do sets with intervals of A-z return symbols in REGEX?
Setting: const texto = 'ABC [abc] a-c 1234'; console.log(texto.match(/[A-z]/g)) Why the set of A(maiúsculo) until z(minusculo), that is to say, /[A-z]/g returned me to [ and ]? The result should not…
-
5
votes1
answer519
viewsRegex to optimize code change using Notepad++
Hello, can someone please help me create a regex expression for the pattern below. I have in my php code the following pattern: htmlspecialchars($str) I need to create an expression that replaces…
-
5
votes1
answer1874
viewsHow to collect data from a web page?
Web data collection, or Web Scraping, is a form of mining that allows the extraction of data from web sites by converting them into structured information for further analysis. Present here your…
-
5
votes1
answer129
viewsDifferent regex strategies to get the same result
I have the following input: Detalhamento de Serviços nº: 999-99999-9999 I need to get the number in a group, for that I would use: Detalhamento de Serviços nº: (\d+-\d+-\d+) However I can’t trust…
-
5
votes2
answers3690
viewsRegex to capture words between two characters
My problem is this: let texto = "teste :1: e também teste :2:" What I need to do is basically take the positions where these characters appear :1: and :2: with regex, since what appears between the…
-
5
votes1
answer371
viewsSecond backslash in metacharacters when the expression is in quotes
When using a pattern between quotation marks a second backslash must be added (\) in the meta-characters that have such a bar, as in this case, for example: /\d+/ -> "\\d+" Code examples: var str…
-
5
votes3
answers193
viewsRegex for this format xxxxxxxxxxxx_v2
How can I make a regex that accepts in this format below: 1q2e5g6s4t5s2u1i5dy1s9u14i2s5u9o_v2 1q2e5g6s4t5s2u1i5dy1s9u14i2s5u9o has 32 characters and then has _v2 - the last 3 are always _v2.…
regexasked 6 years ago Matheus Miranda 5,375 -
5
votes2
answers1974
viewsPick URL with regular link expression
I am trying to extract only the URL if an expression is validated with the tag [monitory]. The expression I use is this: (?=<a.*\[monitory\].*href=["|'][http:|https:]?[\/\/]).*?["|']> And for…
-
5
votes1
answer76
viewsRegular Expression to clone a value in a field
I have the following values: PRO|00000001|GASOLINA ADITIVADA|0101001|27101259| I’d like an expression that changes values and stays that way: PRO|00000001|GASOLINA ADITIVADA|00000001|27101259| I…
regexasked 5 years, 11 months ago Marcos Correia 123 -
5
votes2
answers1371
viewsRegex capturing exactly x digits of a string
I’m trying to make a regular expression in which it captures exactly x digits(specifically in my case x=6). Example: "test 1 n°123456 test end" "2 n°7890123 test end" I want you to return in the…
-
5
votes2
answers3202
viewsRegular expression for repeated characters
Does anyone know if it is possible to check if a string has all the same characters? For example, can characters followed or more than one in the same string, but not all the same: That may: $str =…
-
5
votes2
answers804
viewsRegex for single quotes
I would like to remove the single quotes in the middle of a text, ignoring the ones at the beginning and end, if any. 1st Case: 'Texto e pala'vras' = 'Texto e palavras' 2nd Case: Texto e pala'vras =…
-
5
votes4
answers317
viewsRegex to identify all occurrences of years
I made this Regex to capture the occurrences of years in a sequence of numbers (between 2010-2029). text = '0412020982012' rg = r'20[1-2][0-9]' years = re.compile("(%s)" % (rg)).findall(text) Works…
-
5
votes3
answers115
viewsRegular expression of citations in R
I would like to extract all reference keys I use in a document markdown beginning with the character @. Here is an example of the different ways I can quote a document using this key: line <-…
-
5
votes4
answers319
viewsRegex - set 2 limits and pick up all content inside
In the string below, I need to get the text content from ENERGIA ELETRICA CONSUMO up to the percentage symbol %. That is to say: ENERGIA ELETRICA CONSUMO kWh 370 0,787324 291,31 291,31 29,00% Is it…
-
5
votes1
answer54
viewsMatch between dictonary and array
GOAL: I’m trying to match one dictonary and a array. I want to check if the contents of the array are contained in KEY NAME dictonary, if it is it should return me the whole line of dictonary.…
-
5
votes2
answers219
viewsRegex to search for word inside tag with CDATA
I have a file that contains the following string possibilities: 1st Case: <text><![CDATA[Casa]]></text> 2nd Case: <text><![CDATA[Qualquer texto que tenha Casa no…
-
5
votes2
answers123
viewsAccentuation using regex
I have the following function for name normalization function normalizaNome(nome) { var palavras = nome.match(/\b\w+\b/g), preps = ["de", "da", "do", "das", "dos"]; return palavras.map(function(e,i)…
-
5
votes1
answer109
views -
5
votes1
answer91
viewsWhat is Regexp Match Indices?
I recently found this package, which serves as a polyfill for a new Javascript feature. The proposal Regexp Match Indices was finalized recently, which means it will soon be part of the language. On…
-
4
votes2
answers259
viewsRegular expression error in PHP
Could anyone tell me why this regular error expression in PHP? /:[^\/\\]*/ She’s being used this way: return '/' . preg_replace('/:[^\/\\]*/', '([^\/]*)', $value) . '/'; I am trying to "break" one…
-
4
votes1
answer3396
viewsJava Regular Expression
I am programming in Java and need to filter a String from a regex using the method matches(). I can accept letters (a-z) or numbers (0-9), where that number can have 1 or n digits. I am using the…
-
4
votes3
answers269
viewsHow to reduce the capture of groups in a regular expression?
I have the following expression: /((segunda|terça|quarta|quinta|sexta|sábado|domingo)+(((-feira)?)+(.)+\(([0-9].*)\))?)/im That brings me: Show Trueque performs on Saturday at the CDL theater…
-
4
votes1
answer183
views2 regular expressions in 1
I found the following regular expression to validate javascript email address:…