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
-
0
votes1
answer324
viewsReturn all results using preg_match
I need to return some search results "ex: Digital Agency" from the first page of Google using preg_match + Regex, but it is not returning all 10 values in the array, only the first. How do I…
-
0
votes1
answer302
viewsUncaught Syntaxerror: Unexpected token var
I’m doing a simple test with Regexp on Jsfiddle and I don’t understand why Uncaught Syntaxerror: Unexpected token var Look at: http://jsfiddle.net/cbLs8/ Code: <input type="text"…
-
0
votes3
answers158
viewspreg_replace_callback does not work
I’m trying to replace a variable with preg_replace_callback, but I’m not succeeding, does anyone know where the error is?? $replacements = array( '[PEDIDO]' => $oID, '[NOME]' =>…
-
0
votes2
answers3727
viewsRetrieve content between custom tags using Regex
I need to capture content that is between a custom tag that has a default identifier, for example: <:item>Conteúdo</item>, but I’m not getting the closure of this tag to be customizable,…
-
0
votes1
answer110
views"Escape" file string externally loaded
Problem: I am trying to pass to the database a String containing the bytes of an image that was externally loaded to place in a BLOB field. As always, the bytes of the image have single quotes ',…
-
0
votes2
answers877
viewsturn text into link
I am trying to turn the link of an image into the image inside the tag, however I am having difficulties when there is the image, the same I try to do with the link in case I use the code below…
-
0
votes3
answers424
viewsHow to check if a value starts with a bar followed by a message?
I get a value this way: /{mensagem} and if it were different from that (had not the / before the {mensagem), I wanted him to return me error. {mensagem} serves as variable and cannot be changed.…
-
0
votes1
answer285
viewsIntersection and Subtraction Groupings
I have a question regarding regular expressions. I do not understand how intersection and subtraction work in regular expressions. Could someone enlighten me? [a-z&&[aeiou]] Interseção…
-
0
votes1
answer197
viewsI need to retrieve the information from a page. How can I continue what I started?
<?php header('Content-Type: text/html; charset=utf-8'); $ch = curl_init(); $timeout = 0; curl_setopt($ch, CURLOPT_URL,…
-
0
votes1
answer78
viewspreg_match() [Function.preg-match]: No ending delimiter ' '
I get some help in putting the correct delimiters below: if (preg_match('/^[a-zA-Z0-9_-]+[/]{1}[a-zA-Z0-9_-]+$', $bloco)) { .... }
-
0
votes2
answers56
viewsAdd class to Regex result in preg_replace
I would like to add the class with regex and preg_replace echo preg_replace("/<li\>\s*<p\>[a-z]\)\s/", "/<li class=\"inciso\"\>\s*<p\>[a-z]\)\s/", $documento); This is the…
-
0
votes2
answers1771
viewsPython - take data from file . txt with regex
hello, I am trying to make a program but I am not able to remove the data from the file . txt, would be more or less these in bold. PokerStars Hand #135235596385: Tournament #1228747530, $0.23+$0.02…
-
0
votes1
answer367
viewsREGEXP json search does not work properly when used string with parentheses
I created a regular expression that does a JSON search for the name and value of the field, but it does not work correctly when the searched value contains parentheses, such as a DDD for example, so…
-
0
votes3
answers292
viewsValidate ZIP code in Shell-Script
I’m entering this world of regular expressions, I’m having a doubt, I read about metacharacters, etc. Well, I’m trying to validate a zip code and I’m using the following command and I’m not getting…
-
0
votes1
answer130
viewsMultiple terms in regular expression
I need to search a few specific words in a text. I’m using ER for this. However, as I need to look for more than one word, in some cases the result is unsatisfactory. Below the ER I am trying to use…
regexasked 9 years, 4 months ago Danilo Miguel 332 -
0
votes1
answer263
viewsGetting text within another text
I want to get a List(Of String) of text blocks, but there is a problem: { --isso é um bloco; echo "Aqui tem um } no meio";} and would like to get that way: --isso é um bloco; echo "Aqui tem um } no…
-
0
votes1
answer31
viewsDot-Star problem in Regex
I am trying to create an interpreter (parser) of robots.txt with Regex but I can’t make the expression right. I did several tests in Regex101 and still did not achieve an expected result. My regular…
-
0
votes1
answer31
viewsRegular expression does not detect first entity
That expression: (?<=.*"")\s is not detecting the first space it should detect: <object name="Arrow" id="40" price="$400" description="Uma flecha comum."> the correct would be to detect the…
-
0
votes1
answer58
viewsIs the Regexp validity test correct?
I am trying to validate a password through Regexp, in javascript, but it only returns false when it should actually return true, for having given match value, someone would know if there is…
-
0
votes1
answer124
viewsCatch string first with regex
I need to do a regex for an application from which I need to remove a certain combination of characters from within a string. Explaining the problem better. I have a string that returns from the…
-
0
votes2
answers224
viewsRegular expression to grab Youtube link in text
I have a text in wordpress and in this text has a link to youtube: Health" every Monday at 9:15 with reruns at Fridays, from 1 pm. During the exhibition of attraction, the presenter usually receives…
-
0
votes1
answer40
viewsIf you have this character, discard the capture
How do I stop regular expression from capturing what it has \} in the text? I want you to get all the }, but I want if it’s escaped with the character to be discarded, not ignored. I’m trying that…
-
0
votes1
answer36
viewsReturn separate characters in the same result
It is possible to obtain in the same match (preferably the last) two characters that are in different positions within the string? For example: "xxxxto12b" -> "ab" "xyxyxyyxxxxxc23d" -> "cd" I…
-
0
votes2
answers76
viewsSplit arguments with regex
I have difficulties with regex. I just need to split an input string. Input: "arg1 arg2 arg3 arg4"; Output: [arg1, arg2, arg3, arg4] Input: "arg1 'arg 2' arg3 arg4"; Output: [arg1, arg 2, arg3,…
-
0
votes1
answer1178
views"Input string was not in an incorrect format" when filtering array
After sending a String that is a command keyword to my Arduino through the serial port, I’m trying to take values in a C#application, and a certain string and put them in two different arrays using…
-
0
votes1
answer124
viewsDoubt replace javascript function
Anyone can explain to me what these parameters mean within the function replace (/</g) , (http:\/\/\S+)/g function escape(s) { var text = s.replace(/</g, '<').replace('"',…
-
0
votes1
answer526
viewsCapture part of a string within a pair of <> characters using regex
I’m trying to solve a problem that consists of exchanging words that are between <>. For example, I have the following string: <><PALAVRA outrapalavra>palavra</PALAVRA> In…
-
0
votes1
answer150
viewsWith breaking a Base64 string and assigning to input fields
I have a very large and precise Base64 string breaking there in Multiplus up to 20 thousand characters for no errors when sending it via Hidden field. Each broken piece will be sent in separate…
-
0
votes1
answer38
viewsHow to get these lines and blocks?
I’m creating a parser of a language I’m developing, I’m having trouble separating lines and blocks from code, follow the code I use to return lines: Friend Class Splitter Public Itens As New List(Of…
-
0
votes1
answer178
viewsWhy doesn’t the regex work?
I’m following the playbook OOP Programming with PHP5 by Hasin Hayder (2007) and arrived at the part of Unit Tests. In given exercise, he sets up a method wordCount() and creates some tests for this…
-
0
votes2
answers620
viewsEnable TAB key for next field in Regexp
Good morning, I am developing a form where I have a field "username", in this field I use this RegExp("^[0-9a-zA-Z \b]+$") , works perfectly, however at the time I use the TAB key to advance to the…
-
0
votes1
answer776
views.htaccess - Special character friendly urls
I have the following line: RewriteRule ^usuario\/([a-z,0-9,A-Z,._-]+)?$ index.php?pg=usuarios&usuario=$1 I needed him to accept the characters @ : = ! ? How can I do?…
-
0
votes2
answers363
viewsHow to return letters between points using a regular expression?
I am using Google Drive and would like to use a regular expression to separate characters between points, as below : the Bai Xa men to the Bai Xo I need to put in each column, the content between…
-
0
votes1
answer50
viewsHtaccess does not correctly validate the redirect rule
Has in htaccess in which the regex works perfectly without numbers in the rule, but with numbers does not work properly. RewriteRule ^([a-zA-Z]{1,20})-to-([a-zA-Z]{1,20})-([a-zA-Z0-9-]{1,30})\/?$…
-
0
votes3
answers5600
viewsRemove input letters using Javascript and regular expression
I have an input field that gets a value. I would like to remove letters and special characters from the value of that input, leaving only numbers. I think it would be easier to use a replace with a…
-
0
votes1
answer270
viewsRegex with STD::REGEX in C++
I am developing a C++ system that I need to get some information from a String using Regular Expression, I am using a regular expression that I used in PHP perfectly, but in C++ returns blank. const…
-
0
votes3
answers643
viewsHow to mount the regular expression below
I’m trying to put together a regular expression and I’m not getting it. How do I mount a regular expression that only accepts numbers, bar, and hyphen?
-
0
votes1
answer116
viewsRegex - price validation for Mysql decimal(12,2)
I have a passion where there’s a field price which will be completed by the user. The goal is to accept some entries and block others (validation). The value will be stored in a Mysql database, in a…
regexasked 8 years, 6 months ago zwitterion 2,876 -
0
votes1
answer1004
viewsREGEX - extract some text in a string
i have the following string ==> "The guy from Pamonha crashed his car into the guy’s car" I am wanting to extract starting from ("the guy ...") and ending in ("... the car")$ someone could help…
-
0
votes1
answer50
viewsDifficulty with Regex
I have the following content in a string: |1300|11349|03042016|10857,000|0,000|10857,000|444,470|10412,530|25,530|0,000|10387,000|…
-
0
votes1
answer350
viewsRegex for number format
How can I create a regex (which will be used with preg_match) to the following format 1.123,12?
-
0
votes1
answer1829
viewsHow to create this regular expression?
I need a regular expression that accepts only [, ], - and letras and números to be used as follows: Rules The first character is the [, then comes letters numbers and the - and ends with ]. The…
regexasked 8 years, 4 months ago Leomar de Souza 1,074 -
0
votes1
answer27
viewsRegex, if the variable contains a particular Character
I have a link for exexplo: <a href="#sessao">Sessão</a> And another link : <a href="https://...">Link Externo</a> I would like to know how, I believe by regular expression, a…
-
0
votes1
answer260
viewsSwitch to regex format '0,00' to format '0.00'
I need to make an entry in the database, but I was sent sql to import with the culture (globalization or whatever) wrong. That way the numbers in SQL are in this format: '0,0 ou '0,00' ou '00,00' ou…
regexasked 8 years, 5 months ago Joao Paulo 11,760 -
0
votes0
answers69
viewsI have a question about regex
Well, how do I make pro regex identify that I am wanting to catch the first closing of a tag IE, wanted to catch clinging to the first line of the tag li and soon after wanted to do a foreach to go…
-
0
votes1
answer60
viewsTake part of the SVG ID content with PHP
I have a file SVG and in it has several paths tagged and within the tag has the attribute id which in turn has the name of the state and also the municipality (which is what I need to take). I would…
-
0
votes1
answer157
viewsFind comma in the parameters of a function using regex
I need to find the occurrence of a chain function call, but I need to include the case where there is more than one past parameter, such as: Tower.getType(i,j).initialPrice(f,g); So far I have only…
-
0
votes2
answers699
viewsRegex Python Searching dates
resultado_limpo = ((busca.find_all(string=re.compile(r'\d{2}\/\d{2}\/\d{4}\n\t\t\t\t\t\t\t\t')))) I am trying to find dates in dd/mm/yyyy format need search with year only 2016 and have how I put…
-
0
votes4
answers703
viewsValidate facebook profile URL
How do I validate a facebook profile URL and get the user id? Examples: http://www.facebook.com/walterwhite http://www.facebook.com/profile.php?id=xxxxx And the other variations: htttps://facebook…
-
0
votes1
answer902
viewsAbout Regular Expression in PHP - How to Get Part of a Text?
I’m having trouble picking up part of a text from a page on Wikipedia. I can hold the title that way: $content = file_get_contenst("https://en.wikipedia.org/wiki/Nature_conservation");…