Posts by Mariano • 1,098 points
38 posts
-
6
votes3
answers2037
viewsA: Regex to validate certain date format
Regex is definitely not the right tool to solve this problem. However, I read in the comments that you are studying regex... So just for fun Regex…
-
2
votes4
answers169
viewsA: Which way can I use regular expression to capture just a few link attributes
You can easily get all links with a href that starts with /manga with the CSS selector: a[href^='/manga'] Using Document.querySelectorAll(): links = document.querySelectorAll("a[href^='/manga']");…
-
1
votes1
answer613
viewsA: URL and PORT forwarding in . htaccess
RewriteEngine On RewriteBase / #Se a porta é 80 #E a URL é /fop2 ou /fop2/ #redirecionar para a nova URL RewriteCond %{SERVER_PORT} =80 RewriteRule ^fop2/?$…
-
5
votes1
answer2281
viewsA: Regex no Delphi
\w home a-z, A-Z, 0-9 or _. You only have to repeat it 6 to 20 times, that’s it \w{6,20} From the beginning of the string ^ until the end of the string $. So: ^\w{6,20}$ And in this case, it’s…
-
2
votes3
answers158
viewsA: How do I marry this range of elements?
It’s much easier to remove what you don’t want: ^a\)\s* at the beginning, or \s*<br\s*/?>\s*$ in the end. So: ^a\)\s*|\s*<br\s*/?>\s*$ using the function replace() with the flags global…
-
0
votes1
answer37
viewsA: R=301, htaccess redirect to the new page
You simply have to create a new rule if the requested URL corresponds to produto.php: RewriteEngine On RewriteBase / # Redirecionar se acessar diretamente para produto.php # a) com o parâmetro…
-
1
votes1
answer185
viewsA: Error to 404 when setting Friendly URL in . htaccess
Has a mistake: RewriteRule ^es/guarapari/([0-9]+)/([[a-z0-9-]+)/?$ empresas.php?id=$1&nome=$2 [NC] # ^ # aqui Should be RewriteRule ^es/guarapari/([0-9]+)/([a-z0-9-]+)/?$…
-
12
votes4
answers24927
viewsA: Regex - Picking text up to a given string
Marrying question and answers with an expression If you really want to get married anything up to a letter followed by a letter ), or the end of the string, you can use this Regexp: (regex.)…
-
0
votes1
answer115
viewsA: search thousands of strings in thousands of files
If you are sure that each parameter starts and ends with a word character ([0-9_a-zA-Z]), can use word limits \b. $regex = [regex] "\b$( $WS_URL_CONSULTA_CNPJ_SERASA )\b" $data -match $regex…
-
1
votes1
answer89
viewsA: How to find a string based on a group of regular expressions
I’m using the preg_replace_callback to replace the results of the tests in the $regexList. [...] The problem is that this function picks up the occurrence of the first Pattern in $regexList, instead…
-
0
votes2
answers218
viewsA: I cannot capture ROUTE without using index in URL
The problem is in the flag delimiter: RewriteRule ^(.*)$ index.php/$1 [NC, L] # ^^ # não permite espaços aqui The space is wrong. Switch to: RewriteRule (.*) index.php/$1 [NC,L] Although you don’t…
-
1
votes1
answer57
viewsA: Apply two functions to . htaccess
When Rewriterule matches, the flag [L] (LAST) stops processing other rules. You have to remove it from the first rule. RewriteEngine On #Forçar https RewriteCond %{SERVER_PORT} ^80$ RewriteRule ^…
-
0
votes1
answer55
viewsA: User friendly URL with folder
For the user only home RewriteEngine On # http://localhost/newera/user/home # --> http://localhost/nomeprojeto/usercenter/index.php?user=home RewriteRule ^newera/user/home/?$…
-
0
votes1
answer56
viewsA: How to modify the URL of www.meusite.com/index.php? secao=quemsomos para www.meusite.com/quemsomos?
The rule works correctly, but these two conditions: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d mean that the file (-f) does not exist and the folder (-d) does not exist,…
-
1
votes1
answer535
viewsA: How do I force . htaccess to direct a domain into a folder?
RewriteEngine On # http://mycard.com.br/subdominios --> http://mycard.com.br RewriteCond %{HTTP_HOST} ^mycard\.com\.br$ [NC] RewriteRule ^subdominios/?$ / [R=301,NC,L] #…
-
1
votes2
answers132
viewsA: How to insert a letter between two words in a php string?
For numbers, "e" is used in the middle of these 5 cases: Between dozens and units, from 21 to 99. Between hundreds and dozens or units, from 101 to 999. Between thousands and tens or units…
-
1
votes1
answer118
viewsA: Appropriate PREG MATCH rule
A number whole amid 1 and 12: [1-9]|1[0-2] Grouped: (?:[1-9]|1[0-2]) Followed by a comma or the end of the text ($): (?:[1-9]|1[0-2])(?:,|$) Repeat 0 to 12 times: (?:(?:[1-9]|1[0-2])(?:,|$)){0,12}…
-
0
votes1
answer136
viewsA: Redirect 301 to specific urls
RewriteEngine on #Somente se for o host antigo... RewriteCond %{HTTP_HOST} ^meusite\.com\.br$ [NC] #... redirecionar só quando tiver artigo/ RewriteRule ^artigo(/.*|$)…
-
1
votes7
answers5040
viewsA: Regular expression for accepting numbers and letters, regardless of sequence
Conditions 8+ characters, numbers or letters only: /^[a-z\d]{8,}$/i Minimum 2 numbers: /^(?:.*?\d){2}/ Minimum 1 letter: /^.*?[a-z]/i All together /^(?=.*?[a-z])(?=(?:.*?\d){2})[a-z\d]{8,}$/i To…
-
0
votes1
answer105
viewsA: Transform these Web.config rules into . htaccess
There’s almost no need to explain. RewriteEngine on RewriteRule ^camera/pictures/(.*)_small\.png$ /camera/pictures/$1.png Behold RewriteRule for more information. The second rule rewrites to the…
-
0
votes1
answer178
viewsA: .htaccess does not work the rule
You have to make a part of regex optional. For that, we use a (?:group) with the quantifier ?. ^produtos/([^/]*)(?:/(.*))? # ^^^^^^^^^^ # opcional .htaccess <IfModule mod_rewrite.c>…
-
1
votes1
answer156
viewsA: PHP regex recursive
Let’s simplify: $oper = '[-+*\/]'; //um operador matemático $numero = '(?:- ?)?\d*\.?\d+'; //float $nomes = '(?:var|perg|ind)'; //nomes de função $recurse= '(?1)'; //Vou explicar depois Since the…
-
2
votes1
answer190
viewsA: Make different combinations of words within a sentence
Cannot be done with a single expression using the module re python (although it is possible with the module regex, created by Matthew Barnett, using \G). Addendum (Guilherme Lautert): The reason why…
-
3
votes3
answers149
viewsA: How to replace the extension but remain the title
There’s a problem in using .replace() thus: str.replace(".webm", ".mp4"); What happens if location has ".webm" in the middle of the chain instead of as an extension? var str =…
-
1
votes3
answers2168
viewsA: Validate name field - Jquery
Regular expression /^[a-z\d](?:[a-z\d]| (?! |$)){0,29}$/i Meaning ^ - Circumflex that matches the beginning of the string. [a-z\d] - List a letter or number (not to allow spaces at the beginning).…
-
1
votes6
answers615
viewsA: Regular Expressions with Java Patterns
Use a Lookahead positive. (?=padrão) A Lookahead allows checking whether the group can be found by starting at the position it is in, but without capturing or advancing the reading of the string…
-
0
votes7
answers185
viewsA: Capture year outside the regex
I need to see where the years are above 2017 Regular expression \b0*(?:(?:[12]\d|[3-9])\d{3,}|2(?:0(?:1[89]|[2-9]\d)|[1-9]\d{2}))(?=-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) Test here:…
-
1
votes2
answers404
viewsA: Extract groups with regex
The pattern should match all characters in the text. Between the Session and the date there is no space, but "} | ". The two date alternatives should not have spaces between them: (data1|data2).…
-
2
votes2
answers1971
viewsA: How to capture string between square brackets
Regular expression: \G[^\[']*(?:'[^']*'[^\['*]*)*(\[[^]']*(?:'[^']*'[^]']*)*\]) Code: import java.util.regex.Matcher; import java.util.regex.Pattern; final String regex = "\\G" // Início do texto ou…
-
1
votes1
answer81
viewsA: How to change . htaccess Wordpress via FTP
Wordpress generates the . htaccess in the root of your site. Also, there may be other . htaccess in subfolders. The file closest to the requested URL is applied first. The point before the file name…
-
0
votes1
answer320
viewsA: How to create a user friendly URL with undefined number of parameters
It has been commented that there should be better way to organize folders. This would be the solution. It is assumed that user names are letters [a-z]. .htaccess RewriteEngine on # URL: Reescrita: #…
-
3
votes1
answer107
viewsA: Apache mod_rewrite
I want the first parameter to remain the file, but the second is the value of a variable that will always have the same name RewriteEngine on #Quando há um número ímpar de parâmetros # (eliminar…
-
3
votes1
answer89
viewsA: How to encrypt multiple variables within a php file?
Assuming it always starts with "?cmd=" and ending at the end of the line, you can use preg_replace_callback($regex, $callback, $string) The callback that will be called and passed an array of the…
-
7
votes3
answers331
viewsA: PHP remove a URI snippet with regular expression
Regular expression: /(?:(\?)|&)ordem=\d+(?(1)(?:&|$)|(&|$))/ Substituting: $1$2 Code: $uri = 'http://www.meudominio.com.br/pagina.php?campo=teste&ordem=2&cor=azul'; $re =…
-
1
votes1
answer1766
viewsA: Jquery Masked input with regex?
It is possible to use the jquery-Masked-input, changing the mask with the event onKeyPress, depending on whether the month has a value equal to or greater than 10. var mask = function (val) { val =…
-
0
votes2
answers110
viewsA: Problem with regular expression in Asp.net with Angularjs(1)
Only receive number and if there are 11 digits, the third must be 9. The following regular expression will only accept 10 digits or 11 digits starting with any digit, except 0. If there were 11…
-
2
votes6
answers14943
viewsA: JS Mask for Hours Validation
It is possible to use the jquery-Masked-input, changing the mask with the event onKeyPress, depending on whether the hours have a value equal to or greater than 20. var mask = function (val) { val =…
-
4
votes2
answers1012
viewsA: Validation of Time
/[0-23]/ that is to say 0, 1, 2, or 3. And the same applies to the second case, [0-59] means of 0 to 5, or 9. Instead, use this other: var mask = function (val) { val = val.split(":"); return…