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
-
2
votes2
answers183
viewsProblem with Regex in PHP
I have the following function that is used to take special characters from a string: function removeSpecialChars($string){ //List (Array) of special chars $pattern =…
-
2
votes2
answers787
viewsHow to select the logUser attribute only on the main JSON object using Regex
I need to select the attribute logUser only in the JSON main object if it comes with value or null. Ex: logUser: 100 | logUser: null { "id": 1, "numeracao": "001", "logUser": 100, "permissionario":…
-
2
votes1
answer301
viewsRegex by PHP position
I have the following string: 'QD 10 LT 20 PA 30' Using the preg_replace() in PHP I can only manipulate numbers. For example, take the first group of numbers: $string = 'QD 10 LT 20 PA 30'…
-
2
votes1
answer962
viewsHow to put parentheses or brackets in regular expressions in Javascript?
If I do something like: var word='carro'; var re = RegExp( '\\b'+word+'\\b','g' ); It works perfectly, but what follows: var word='['; var re = RegExp( '\\b'+word+'\\b','g' ); Returns: Invalid…
-
2
votes1
answer1326
viewsHow to validate a field To accept only Letters/Numbers using Regex
I am creating validations for every Property of my classes. I am using a component called AbstractValidator. Example: protected void ValidarChamadaTipo() { RuleFor(p => p.ChamadaTipo)…
-
2
votes1
answer1776
viewsRegular expression for e-mail validation with REGEXP_LIKE on Oracle
I am trying to introduce an additional validation in my regular expression in Oracle 11G using the REGEXP_LIKE. I want the expression to detect two consecutive underscores but to ignore if they are…
-
2
votes1
answer76
viewsREGEX extract everything from a group
I’m trying to extract some information from an HTML, but the regex doesn’t work, I’m pretty sure it’s not picking up spaces, something like that. https://regex101.com/r/LPJO4Z/1…
-
2
votes2
answers197
viewsRegex able to ignore the prefixes of a word
I’ve got those regex next: regex_list = [ '(?:arquiv|auto)(\w+) (?:auto|arquiv) (?:definitiv)', '(?:arquiv|auto)(\w+) (?:auto|arquiv)', '(?:arquiv)(\w+) (?:definitiv)' ] My goal is to capture…
-
2
votes1
answer450
viewsRegular Expression to validate password - PHP
I searched here in the OS and tbm in Google, but I did not find something to act as I would like, I am also not good with regular expressions, I confess that I have some difficulty and I would like…
-
2
votes2
answers299
viewsRegex - Selecting the first occurrence of a sequence of a number block
I have a String sort of like this: 987654 original4343 - Co 123456 asd.pdf This String may vary the groupings of numbers, but what I need is to get the grouping that has 6 digits. So I did this…
-
2
votes1
answer645
viewsHow to create a regex to delete letters and number after the 3rd decimal place
I need a regular expression with the following rules: Erase all that is letter Delete all number after 3rd decimal place For example, if I type 34,444 any next number will be deleted. If I type a…
-
2
votes2
answers3481
viewsRegex for strong password
I want to create an expression that creates a password with: 8 characters minimum 1 Capital letter at least 1 Number at least 1 symbol at least: $*&@# If possible, also do not allow equal…
-
2
votes2
answers253
viewsExtract content from "Name:" field until end of line
Given a string in the following format: 'a1in1iionia\n\nDados do cliente\nNome: Foo\nE-mail: [email protected]\n' I need to extract the full content from the "Name" field. For this I wrote the code:…
-
2
votes1
answer121
viewsRegex to get comments from a CSS
I have this CSS: :root{ --bodyBackgroundColor: #ffffff; // pegar o comentário não importando o tamanho --bodyTextColor: #ffffff; // outro --buttonBorderFocus: #1d2124; // testando } Response…
-
2
votes2
answers806
viewsRegex date validation with 2/2/4 characters
Looking hard, I found some explanations on how to validate date with Regex but my knowledge in regex is a little limited yet. With some modifications in the explanations I found, I came to a nice…
-
2
votes2
answers208
viewsCatch everything between line break tags
<div class="1" >quero pegar AQUI DENTRO PODE TER quebra de linha... paragrafo... espaços várias outras tags html... qualquer coisa... </div> How do I marry this div with regex? Example:…
-
2
votes0
answers38
viewsregex in Analytics API
I’m writing a code in Google App Script using the Google Analytics API where I make a request using a regex filter. A similar example is written below: var id = xxxxxxx; var startDate =…
-
2
votes2
answers1352
viewsValidate field to accept integer and decimal numbers
How to do with Javascript, so that one input text type accepted only whole numbers and decimal numbers up to 2 decimal places. Ex: 1 - true 1,1 - true 1,11 - true $("body").on("input", ".number",…
-
2
votes1
answer531
viewsGrab only some attributes of HTML tags
I have several inputs, from a curl, but I just need the name and of value of these inputs: <input type="hidden" autocomplete="off" name="timezone" value="180" id="u_0_9"> I have this code:…
-
2
votes1
answer42
viewsRegex for two string hypotheses simultaneously
I have the following input, and I do a line-by-line interaction at all. D b1308 pspE; thiosulfate sulfurtransferase PspE K03972 pspE; phage shock protein E B 09193 Unclassified: signaling and…
regexasked 5 years, 7 months ago FourZeroFive 1,231 -
2
votes1
answer699
viewsRegex to validate a 5-digit alphanumeric field
I’m doing a regular expression to validate an alphanumeric field of up to five digits. The first field should be numerical only, the rest can be letters or numbers: ex: 1A, 11A, 111A, 1111A, 1, 11,…
-
2
votes2
answers169
viewsRemove all after the second occurrence of a comma
I have a df with addresses and want to remove everything that is after the second comma. exemplo <- c("Rua Pajé, 30, apto 44", "Av. Brasil,55, blocoB") What I’ve already tried:…
-
2
votes1
answer534
viewsCatch string inside a text file using regex in Python
I would like to know how to get a string in this ' XXXX ' format inside a text file, using regex. I have tried several methods but without success: import re f = open('infos', 'r') padrao =…
-
2
votes1
answer542
viewsRegular Expression to separate Substring from String
I have the following sentence: "SUZANO ZANO ZMES ZDIA ZANO_MES" and I need to remove from it only "ZANO ZMES ZDIA", recalling that the ZANO of SUZANO and of ZANO_MES cannot be related. I used the…
-
2
votes2
answers933
viewsPick up only the final stretch after the regular expression bar
I did a general search here and on Google and I came to find something that worked partially. I have the following text pattern: 030.000.208 OUTRA COISA 001.005.001 ALGUMA / COISA AQUI COM - TAMBÉM…
-
2
votes2
answers1003
viewsHow to do a regex to capture a sequence in numbers with dots and strings
Examples are: 1.1. FLESH 1.1.2. BRAIN I want to make sure I get sequences number.number. ... space and a high-box string (can’t be low box). I tried this: reg = r'[1-9][.]+\s\b[A-Z]*' However, the…
-
2
votes3
answers227
viewsAdd a string before a given word using Regex
I’m reading a file with a C code and turning it into another. I would like to replace the name of a variable that comes before or after an operation character by replacing it with "x" +…
-
2
votes2
answers962
viewsSearch Only the numbers of a String using Regex in python
I’m trying to clear a column of a process dataset and the number of processes come in various forms: 5080847-62.2018.4.04.7100 033/2.17.0001000-7 I want to leave only numbers and remove the other…
-
2
votes2
answers790
viewsCheck with REGEX VBA if phone is fixed or mobile (checking 3rd number in regex)
I have to do a REGEX VBA that check the phone number in this pattern, I thought I would try to identify the 3rd number and check if it is different from 9 or 8, getting like this: Cellular…
-
2
votes2
answers161
viewsHow to remove column fields from a regular expression select?
I need to use a regular Javascript expression to know which columns are passed in a query select. For example: passing "SELECT nome, sobrenome FROM table" the expression would return to me…
-
2
votes1
answer192
viewsReplace HTML tag with text with regex
I need to replace an HTML tag (with a specific attribute) with a text, follow my example below: String stringTest = '<variable data-id="1" name="test2" style="background-color:red;">Variable…
-
2
votes1
answer171
viewsRegex for split comparison operators
I’m having trouble putting together a regular expression that meets the following condition: String formula = " 100 != (50 + 20 + 30) "; String arr = formula.split(" somente os caracteres: '=',…
-
2
votes2
answers541
viewsBold words from my HTML using Regex
Basically, I need to select all the words "Pattern" in my HTML with Regex and then replace them with your version in bold through Javascript. My code works, however, only for the first element, for…
-
2
votes3
answers67
viewsRegex is not working with file_get_contents
I have a problem about regex and I come here to ask you for help. I’m trying to get a file value .chr by regex, but it does not return any match, I find it strange because I have tested in regex…
-
2
votes2
answers89
viewsRegex because only true if put above 5 numbers?
function checkreg() { var reg = /[0-9]{4}/; var verificaInput = document.querySelector("#agencia").value; console.log(reg.test(verificaInput)) } <label> <input type="number" name="agencia"…
-
2
votes1
answer175
viewsRegular expressions for one or more telephone numbers
I have a regular expression that validates mobile phone and landline, but the user can only add a fixed or a mobile phone, it does not allow to add more than one number. How do I for expression…
-
2
votes1
answer72
viewsSelect desired value with REGEX for two different standards
I have the following data entry: INSTANCE-hostname:Sys INSTANCE-hostname-INSTANCE_00:Ins You will always follow this case, where only what interests me is the value hostname, that is, my OUTPUT…
-
2
votes4
answers180
viewsHow to remove the last space in each line from a textarea?
I use the function below to replace all the different characters of numbers in a textarea with "spaces". The problem is that at the end of each line of the textarea always has a space. How to delete…
-
2
votes1
answer285
viewsCombine multiple Regular Expressions into one
Is there any way to combine multiple regex patterns into a single expression, to be used in re.match() or re.search(), for example? starts_with_Y = '([Y][A-Za-z0-9]{6}([-][A-Za-z0-9]{1})?\s)'…
-
2
votes1
answer335
viewsRegex to filter words, as long as they are not contained in other words
I am trying to create a Regex that filters by certain words, to be used in the validation of the name entered by the user in a conversation with a chatbot. Since it’s about filtering out bad words,…
regexasked 5 years, 4 months ago Daniel Bertoldi 97 -
2
votes2
answers637
viewsRegular word start expression until next number
Needed a regular expression to pick group from a string. Let’s imagine the following string: (a >3) and ( b + c = 4 and M < 45) and (d + e = 6 and M between 40 and 60) and z>10 I needed to…
-
2
votes2
answers75
viewsGet specific value in a txt file
I am trying to get two specific values on each line of a txt file. As an example: 15/06/2016 R$ 638,69 R$ 2.562,46 15/07/2016 R$ 672,43 R$ 2.533,51 15/08/2016 R$ 658,93 R$ 2.504,75 15/09/2016 R$…
-
2
votes1
answer49
viewsRegex checking if there is no character on a line
I’m having trouble putting together a Regex that checks if there isn’t a character at any point in a row after a pattern. I have the following log: 3/9/18, 17:47 - Pessoa 1: Oi gente! 3/10/18, 22:59…
-
2
votes1
answer82
viewsHow to find, retrieve and delete a certain value in a multiline string in Javascript?
I need to locate a value (has defined default) in a text, recover it and then delete the record. const content = `Exemplo de texto: Lorem Ipsum is simply dummy text of the printing and typesetting…
-
2
votes2
answers822
viewsRegex to pick sequence of letters or numbers
I have a website where I do a lot of youtube embed, so to make it easier I thought about using {youtube 54sd3} for example, and at the time of printing the result it replaced with: <iframe…
-
2
votes1
answer149
viewsRegular expression case insensitive in a dataframe
I have a dataframe with some tweets that were collected according to the keyword. How do for example to extract at once only the lines with #flamengo and all its variations, such as #Flamengo,…
-
2
votes1
answer87
viewsRegex with lookbehind does not work in Firefox
I created an Angular project and am using the following regular expression: export const INTERFACE_REGEX = new RegExp(/(?<=.*\/)(.*?)(?=@|-.+)/gi); It happens that when using Goggle Chrome the…
-
2
votes2
answers181
viewsReading and processing XML file from a CVE (Common Vulnerabilities and Exposures) database with Python
By using the Annexes lista.txt and cve.xml develop a Python script that: open and read the ". xml" extension file made available at the end; search the file for all occurrences of CVE ID in the…
-
2
votes1
answer288
viewsQuery two or more words in a string
I need to make mine select bring only records whose description has the words "RACAO" and "ROYAL". I’m using Regex to make it easier, but I don’t know why you’re bringing in records that have…
-
2
votes2
answers148
viewsString handling with Regex
I have the following string: const string = 'Isto é uma frase $[var_test["aaaa"].bbb], mais coisas $[var_test["ccc"].ddd].eee.fff mais coisas.' The dynamic elements are: var_test | aaa | bbb | ccc |…