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
-
3
votes3
answers851
viewsRegular expression to find word exception
I’m looking for a certain recursive function which I can’t remember the name of. For this I set up the following ER: function (\w+)\([\x00-\xFF]+\1\( That will necessarily search for all functions…
regexasked 10 years, 2 months ago Guilherme Lautert 15,097 -
3
votes1
answer503
viewsHow to replace a series of whitespace with just one in a string in R?
How do I replace a series of blank spaces with just one, in R? For example, suppose we have a string: x <- " non non non non" I want to make the content of x: "non non non non non non non non".…
-
3
votes1
answer2070
viewsHow to delete text in parentheses with regexp?
I am developing an HTML5 application that uses the Wikipedia API to give the definition of what we ask for. I used the code that they made available in a forum of another language of Stack and, in…
-
3
votes2
answers3899
viewsPicking text between two words with regex
I would like a light for my problem. My goal is to pick up the list below by dividing the blocks between the words LOREM and LOREM but I don’t want to pick up the whole text that follows at the end…
-
3
votes2
answers168
viewsHow to select with regex?
I am trying to format text of the following type 123,345,234 //tem que ficar 123345,234 abc,def,adf //tem que ficar abcdef,adf 123,345,678,abc,qualquer,coisa //tem que ficar…
-
3
votes2
answers1266
viewsRegex time greater than 00:00
I’m developing a regex validation using the System.ComponentModel.DataAnnotations and RegularExpression from Asp.net mvc C#, in this regex it is necessary to validate unlimited duration time in…
-
3
votes2
answers236
viewsRegular expressions
I have a little difficulty to assemble the regular expressions, I’m trying to work with this code: <?php $url = file_get_contents('http://ciagri.iea.sp.gov.br/precosdiarios/');…
-
3
votes3
answers3283
viewsRegular expression for dates without tab
I need to know if a sequence of 8 numbers is a valid date in the dd/mm/yyyy format. The closest I came was using this expression: /^[0-3]{1}\d{1}[0-1]{1}[0-9]{1}[1-2]{1}\d{3}$/gm; But it is…
-
3
votes1
answer1748
viewsConvert text links to html link
I saw the solution from here Convert a text link to a href link and several others and eventually adapted to my need, but there are some problems. I need to convert the links and the image links…
-
3
votes3
answers3527
viewsSwap characters inside a string, in a string
Simple question: I just want to replace the characters A inside the field " " and not what is out for a B, example: aaaaaaaaaa"aaaa"aaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa…
-
3
votes3
answers4057
viewsGet content that is in parentheses using regex
I’ve been studying quite the regex, but I found myself trying to "clear" a text, leaving only the first occurrence, and the data in parentheses, the string is like this: $string = "Mais de - valor:…
-
3
votes3
answers9295
viewsEmail verification in Java
I am doing a simple test to check if the user has typed a valid email. So I have an error of syntax in token "@" invalid Assignmentperator. Code of the main class: public class Email { static String…
-
3
votes2
answers3054
viewsFormat CPF column with regular expression
In a table containing the column CPF I would like to format it in order to present the content properly. By appropriate way I refer to the format 999.999.999-99. It is possible to format this…
-
3
votes2
answers987
viewsPHP: Picking up function argument with preg_match_all
Good afternoon: I’m picking up to pick up the value of calls to a certain PHP function straight from the source code. What I need to do is sweep each of the lines of the source code, and if there is…
-
3
votes1
answer214
viewsRegular expression, picking numbers before a text
I wanted a regular expression to catch the minutes in a string with this format: 1 min 10 min I made that expression. \d(?= min) The problem is that it only takes the last number, the closest to the…
-
3
votes1
answer621
viewsPHP Regex remove IMG attributes and change SRC
I have the following string with the html: teste = "<img src="image/teste.jpg" alt="" width="32" height="32"> <p>teste</p> <img src="image/teste2.jpg" alt="" width="132"…
-
3
votes4
answers824
viewsRegular Expression to get what’s outside of brackets
Sample text: Itaú [123.456,89] To get what’s inside the brackets (including the brackets) I used: \[(.*?)\] The question is how to get what is outside? I imagine it’s a denied list, something…
regexasked 9 years, 5 months ago Danilo Tostes 119 -
3
votes2
answers374
viewsWhat are the valid delimiters for preg_regular expressions?
What are the valid delimiters for regular expressions in function preg_*? I know we can use some of these (/, ~ and #), as shown in the example below: $numero = '0.12.13'; preg_replace('/\D+/', '',…
-
3
votes2
answers108
viewsRegex - picking certain values - PHP
I’m in doubt, I tried to read several articles on regular expressions, but it still didn’t fit in my mind, I get confused. I have a certain string…
-
3
votes1
answer1766
viewsJquery Masked input with regex?
I put the following script to put only month and year in input, and set regex to accept typing from 1 to 12 for months: $.mask.definitions['X'] = "^([0-1]|1[0-2])$"; jQuery(function($){…
-
3
votes1
answer211
viewsURL rewriting with "+" sign (same as Google+) . htaccess
I’d like to write a rule in . htaccess with Rewriterule using the plus sign (+) for a Google-like url, like this: meusite.com.br/+alguem be interpreted meusite.com.br/? track=someone or…
-
3
votes1
answer524
viewsHow to create expression to allow just a few characters?
I am creating an input where an onKeyUp checks the entered characters, it should validate the following: No maximum number of characters The first digit should only be numbers [0-9] The code is…
-
3
votes1
answer11096
viewsValidate credit card with js
I would like to know how to validate the credit card through Js. Visa starts with 4 Mastercard starts with 51, 52, 53, 54 or 55; American Express starts at 34 and 37 Someone knows the best way to…
-
3
votes1
answer545
viewsInputmask by the model
Hello, I’m using the plugin jQuery - maskedInput, where I take the id of my input and make the mask: $("#CPF").mask("999.999.999-99"); is working, only that would like to use this mask through the…
-
3
votes1
answer80
viewsRegex not to escape just < > =?
I currently have the following regex: "/([^\w\.\,]+\s*)/" It escapes, letters, numbers, commas and dots followed or not by space. How do I let it escape everything except the characters: < > =…
-
3
votes1
answer61
viewsDoubt with Regex
Good night. I need a regular expression that can capture the numbers/expressions before and after a certain character, like this one ^. For example, in the string below I need her to return me (5 *…
-
3
votes1
answer1732
viewsreplace with regular expression (regex) ignoring accents
I recently changed the friendly url, because the querystryng used for searches was filtered to without accents. Regarding the queries to the database regardless of whether the word has accent or is…
-
3
votes2
answers1532
viewsCapture text between two known characters
I need to pick up any text and find the words (or phrases) that are between two specific characters { and }, in that case. I can do this by capturing the delimiters together, using the expression…
-
3
votes1
answer318
viewsRedirect all media requests(css,js and images) with htaccess
I am building an MVC application and was having some problems with the file path css,js and images no html... I was given a solution to use the tag <base> to define the path that all html…
-
3
votes1
answer271
viewsRegular expression in Pattern
I have a text input that I’m validating with regular expression, the expression rule is the following: it starts with a number between 0 and 2 and then 6 more random numbers, but I don’t know why it…
-
3
votes1
answer254
viewsReplace string by holding the box (uppercase/lowercase)
How best to replace a pattern with a string keeping the box? For example, DAdo -> LAdo or dado -> lado.
-
3
votes2
answers1104
viewsRegex string javascript
I need a regular expression that removes all special characters, and spaces of a string if it is an accented letter remove only the accent. Someone would know to help me ?
-
3
votes1
answer96
viewsThe end of a capture in a regular expression
I don’t know which title could be better than that, because I don’t really understand technical terms related to regular expression. But let me describe my problem. I have a code, where I get a…
-
3
votes1
answer84
viewsAsp.Net 5(Core 1.0) Class Library System.Text.Regularexpression
How to use the namespace System.Text.Regularexpression in Asp.Net 5, I’m with a project and went to upgrade it to Asp.net 5, my problem was that I can’t use regular expressions in it and n can…
-
3
votes2
answers1146
viewsHow to make a regular expression to remove only the hyphen without removing the hyphen arrow
I have the following expression: 00000-001->22222-222 I wish she’d stay like this: 00000001->22222222 I’ve tried so many ways on this website, but I’m not getting it.…
-
3
votes1
answer140
viewsHow to escape all metacharacters using Pattern.Compile(.)?
Filing cabinet: ftp://paginaqualquer.html https://othersine.net/ http://mydeletina.php?id= My code: public static void main(String[] args){ //Supondo que o readLine() esteja no loop != null String…
-
3
votes4
answers31555
viewsRemove special characters and accents in javascript
People I’m trying to remove special characters in javascript. But I have a problem, the character is being deleted and this is not what I wanted. I would like only the special character to be…
-
3
votes2
answers468
viewsRegular expression to replace src attribute contents of html <img> tag
Hello, I don’t understand almost anything about regular expression, so I wanted you to help me with an expression to replace only what is in double quotes in the src attribute of the html tag, that…
-
3
votes1
answer27947
viewsFormat CPF or CNPJ field using Regex
I would like a regular expression (REGEX) to format the CPF or CNPJ field This is the code I’ve come up with so far: String cpf ="09551130401"; cpf =…
-
3
votes1
answer459
viewsValidate google key api
I am making an application, where I will have to validate a google maps API key. The problem is that I do not know what standards it follows: AIzaSyA-OlPHUh2W7LUZXVjQjjxQ8fdCWdAASmc Here it is…
-
3
votes5
answers50
viewsHow to change the end of a name
How to change the end of a name for example WELITON, MAICON, WELIGTON for WELITOM, MAICOM, WELIGTOM
-
3
votes2
answers535
viewspreg_match(...) for various text types
How can I validate the texts below? Letters (including accents) and numbers (without spacing), separated by . or . e.g. 'olá123' Integers and/or decimals. ex: '22' or '2.2'
-
3
votes1
answer77
viewsR - match and add string
n <- c("alberto queiroz souza","bernardo josé silva","josé césar pereira","alberto, q-s.","alberto, queiroz souza","alberto, q. s.","alberto, q c", "bernardo, j. s.", "bernardo, j. silva", "josé,…
-
3
votes1
answer101
viewsIdentify if and endif with regex?
In an example of the OS found: <?php $a = 22; $b = 33; $template = ' [if $b>0 ] B > 0 [/if]'; // IF - ENDIF preg_match_all('/\[if(.*?)\][\s]*?(.*)[\s]*?\[\/if\]/i', $template, $regs,…
-
3
votes3
answers2939
viewsIdentify repeated numeric characters in sequence
With the expression [\d]{9} I can identify numeric characters if they are repeated nine times in sequence, but I only want to identify if they are the same characters, for example: 111111111 //…
regexasked 8 years, 3 months ago Marcelo de Andrade 7,261 -
3
votes1
answer79
viewsDoubt about regex
Have this string and I need to go through it taking only the values that are inside the (). To string is : String estados = “(1, ‘AC', ‘Acre’), (2,’AL', ‘Alagoas’), (3, AM, ‘Amazonas’)… “ I rode the…
-
3
votes1
answer89
viewsHow to encrypt multiple variables within a php file?
I’m using php to read a file to a $string, he owns some words variables that I need to find and replace with others, that is, I need to get these variables, encrypt them with AES and write again…
-
3
votes2
answers672
viewsRemove comma out of square brackets - Regex
I am trying to remove the comma that is located outside the brackets of the following excerpt: 2||Azul||Cor||["#1983ff", "#1983ff"],3||Amarelo||Cor||["#fff73d"] I need the comeback to be that way:…
-
3
votes2
answers2696
viewsRegular expression
I have a question how can I make a regular expression to remove phone masks, Cpf, cnpj. I managed to get ("-") out of the zip code String[] cepText = edtCep.getText().toString().split("-"); there in…
-
3
votes1
answer95
viewsReplace words
I wonder how I compact the lines of a txt. For example the lines are broken by \n but are still part of the same sentence. SOCIAL HISTORY:Denies tobacco or alcohol use. PHYSICAL EXAMINATION: VITAL…