Posts by Guilherme Lautert • 15,097 points
356 posts
-
2
votes1
answer203
viewsA: Search with REGEX in VI
When performing a search on vi it does not directly interpret that what you are using is a REGEX, such that what it searches for is actually a String. So you should use the same logic when passing a…
-
3
votes1
answer448
viewsA: Simultaneous connection on straight seats PDO
Your class is almost ready for this, just a small adjustment: <?php class connection { public static $conn; private static $last; // <--- parametro novo para controle da ultima conexão criada…
-
2
votes3
answers200
viewsA: How to pick up parts of a text in php
Seeing your text to analyze along with the PHP tag, I imagine you are doing a CURL. Suggestion PARSER The ideal in these cases, because it is an HTML analysis, is to use a parser. Should you do so I…
-
0
votes2
answers724
viewsA: Regular expression to deny anything other than social reason
If the sentence always follows this pattern. Just check the borders. Left : Preceded by a CNPJ, end of CNPJ \d{4}-\d{2} Right : Followed by a monetary value : \d+,\d{2} Resolution Pattern :…
-
4
votes12
answers208289
viewsA: How to format date in Javascript?
Based on this question I have assembled a small git with some auxiliary functions for these purposes. Using the methods I’ve provided you can do so : var d = new Date();…
-
3
votes3
answers841
viewsA: Is there a javascript function that marks a selected random text with the mouse?
From what I understand, it would be something related to that? var textMark = null; var textStart = 0; var textStop = 0; function getSelectionText() { var text = ""; var select = null; if…
-
5
votes1
answer142
viewsQ: What is the difference between the new JOIN operator and the previous ones?
I was looking at some examples of SQL in Oracle, and I noticed that it is possible to do only JOIN. Example SELECT T1.*, T2.desc FROM table1 T1 JOIN table2 T2 ON T2.id = T1.id_table2 Question What…
-
0
votes3
answers524
viewsA: Regex in javascript for partial match in URL
The best way to work with url is to put it in a string and use Regexp, as it automatically escapes the bars, so you can write your test url normally. var url = "www.url.com/foo/bar/"; r = new…
-
0
votes2
answers113
viewsA: Querie mongodb with regex
What you want has nothing to do with REGEX, as it is necessary to perform arithmetic operations. Resolution CREATE TABLE prefixos( prefixo INTEGER ); INSERT INTO prefixos (prefixo) VALUES ('429'),…
-
1
votes2
answers972
viewsA: Regular expression with specific ending bring 3 first characters
The abstraction that you showed in your own answer is correct, but let’s see how REGEX would be completely. (\S{3})\S*?m\b Explanation I can divide this REGEX into 3 parts : (\S{3}) - Captures 3…
-
2
votes2
answers102
viewsA: Regex lookbehind
Rules (as I understood) It should start with I or O. [IO] must be followed by at least 3 digits. After the digits and if you start text you should capture the next 12 characters. REGEX Standard…
regexanswered Guilherme Lautert 15,097 -
1
votes2
answers101
viewsA: Regularexpression allow greater than 0.00
Solution ^(?!^(0{1,3}\.?)+(,00)?$)(\d{1,3}\.?)+(,\d\d?)? Be Running on REGEX101
-
3
votes7
answers185
viewsA: Capture year outside the regex
Using the Reply from @Marlysson. And adjusting for logic you need : The number 65321 represents the year and is a year that even exists (invalid), need to see where the years are above 2017 to…
-
1
votes6
answers615
viewsA: Regular Expressions with Java Patterns
What you want is a check. The rule says, contain : 2 characters a 2 characters b or more Note that in the b the "or more" part is irrelevant because if you have 2 b is already valid. Resolution…
-
0
votes2
answers2120
viewsA: How to stop a Javascript function that uses setTimeout
I think what you want is this: String.prototype.lpad = function(length, char){ if(!char){ char = 0; } var text = this.toString(); while(text.length < length){ text = char.toString() + text; }…
-
2
votes1
answer104
viewsA: Problems with PHP regular expressions?
First of all \s It’s not "space"!! You can see what the \s here. Problem From what I noticed you also want to capture accented characters. For this I use modified u, approached here. To capture both…
-
2
votes2
answers157
viewsA: Regular Expression
You already have almost all of it, just change the ending: #^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d_ /.-]{8,}$#. Remembering that \w is a summary for [a-zA-Z0-9_]. Thus remaining :…
-
2
votes3
answers610
viewsA: Regular expression for email in C++
First of all I don’t know what the purpose of b, I believe it could be the \b defining the boundaries of string. Vanishing that to REGEX be it : /[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\.[A-Z]{2,4}/…
-
9
votes4
answers1173
viewsA: What does the regular expression "/(?=(?:...)*$)/" do in detail?
This REGEX is very interesting because it combines some interesting factors. Factors We know that REGEX is used to capture certain content of a text/string. We also know what split divided by the…
-
0
votes4
answers111
viewsA: Get content between tags [x] and [/x] with Regular Expression
The ideal when capturing markup content is to have the markup pattern in a group. Example Dialing [pt-br][/pt-br], the standard is the pt-br. Dialing [en-us][/en-us], the standard is the en-us. Why…
-
4
votes3
answers1157
viewsA: Regex check IP
Solution /^((1?\d{1,2}|2([0-4]\d|5[0-5]))\.){3}(1?\d{1,2}|2([0-4]\d|5[0-5]))$|^$/ Explanation Note that you want to validate IP so you cannot simply use \d{1,3}, because you’d be accepting 999.…
-
4
votes4
answers3526
viewsA: How to pick a String that is between Javascript tags using Regex
Ideal for these cases is to think of as much information as possible that generates a capture pattern. Example You said you want what comes between < and > Do you consider it to be an email?…
-
2
votes1
answer1567
viewsQ: Onload event for iframe
Question Let’s say on my website I have a iframe reserved to upload a possible external page, and this iframe be with display:none, how I could create in callback to fire at the end of loading this…
-
3
votes3
answers212
viewsA: Capture the WHERE clause of an SQL query
I think what you want is to get the where. First let’s check what can come after the command where. Post-following commands of where Second postgres. Seeing only the most common GROUP BY HAVING…
-
3
votes3
answers210
viewsA: How would I look regex to handle this case?
Criteria (For what I understood) Must separate words To identify the separation and next word starts with uppercase. If all letters are uppercase you should not separate. (CPF) The letter after…
-
39
votes4
answers3861
viewsA: What are the risks of using permission 777?
TL;DR; Giving permission 777 is the same as : "Trust everyone, no matter who you are". "Allow anyone to do what they want". You "trust" no one, absolutely no one, will do nothing you do not want and…
-
2
votes1
answer1183
viewsA: How to create Pattern (input mask) with jQuery Validation Plugin?
For this you can use the jQuery Mask. $(document).ready(function(){ $('.cpf').mask('000.000.000-00'); $('.cnpj').mask('00.000.000/0000-00'); }); <script…
-
1
votes1
answer656
viewsA: Run script after 20 seconds
To do what you want first keep your HTML hidden through the display:none; in the CSS. Then just create the timer and change the display:none for block that he will display; You can do this with pure…
-
3
votes6
answers906
viewsA: Convert text from div to number
var text = document.getElementById('our_price_display').innerText; // APENAS DIGITOS E , var number = text.replace(/[^\d,]/g,…
-
3
votes2
answers734
viewsA: How to remove "disabled" attribute from the parent select option?
Instead of disabled or readonly, hide the option. var unique = 1; $('select.player').on('change', function(){ var options = $('.player').find('option').filter(function(){ return unique ==…
-
2
votes3
answers7377
viewsA: submit a form with jQuery by clicking a button outside of the form
I created something more generic that works like the for of label To use just create button[type="submit"] or input[type="submit"] or .submit Add an attribute for with the form id you want to send.…
jqueryanswered Guilherme Lautert 15,097 -
3
votes1
answer76
viewsQ: How to know if the past object is a DOM element?
I’m working with functions I must pass on (Mandatorily) an element GIFT. This function will work with the properties of this DOM element. Example function changeValue(elem, value){ elem.value =…
-
1
votes1
answer343
viewsA: Collecting links in a text file
Using a simple logic. Every Url starts with http and ends at the first space. You can use the pattern: .*(http[^ ]+).* Since you have multiple lines, but the urls are not broken into 2 lines, use…
-
18
votes2
answers534
viewsA: What can make a regular expression slow?
Briefly How specific she is. The number of quantifiers you are using. What is a REGEX You should remember that, regardless of the language/library, regex are Deterministic finite automaton, which…
regexanswered Guilherme Lautert 15,097 -
3
votes1
answer906
viewsA: Vertical lines Google Chart
You can reproduce this effect using "annotation" : Add one more column with the role "annotation". {type: 'string', role: 'annotation'} In their options adds the option annotations: { style: 'line'…
-
2
votes3
answers1441
viewsA: PHP Regex Catch the html tag
I won’t go into all the explanations about do not use REGEX for HTML again. I think what you want is this :…
-
0
votes1
answer96
viewsA: Cookie or Session in Wordpress
First don’t use $_COOKIE he’s not safe. related link Like you said, you’re creating an independent page. The first thing you have to keep in mind is : Nothing that can be taken advantage of. What…
wordpressanswered Guilherme Lautert 15,097 -
3
votes2
answers48
viewsA: Reduce this jquery to only 1 block and not 3, how do I do?
You can do this by creating a new class generic for all elements. Example used the class show. $('.show .icon-info').mouseover(function(){ $(this).parent().find('.tooltip-info').show();…
-
3
votes3
answers518
viewsA: How do I fill address data through CNPJ?
You can try searching the CNPJ on website of the IRS. Process Use some service of Curl or Soap via server to simulate a client and retrieve the information. Use an HTML parser to retrieve desired…
javascriptanswered Guilherme Lautert 15,097 -
3
votes2
answers480
viewsA: Single vs. Double Quotes in PHP Regex
To response from the Ivcs explains very well the part of the quotes, just complementing the point that generates your problem. Problem You have a double problem here: "/\/path\/to\/folder\//". And…
-
0
votes3
answers2458
viewsA: How to delete Input Placeholder when Clicking inside the Field
Rode with pure JS. var inputs = document.getElementsByTagName('input'); for(var i = 0; i < inputs.length; i++){ var input = inputs[i]; input.addEventListener('focus', function(){ var place =…
-
5
votes3
answers1831
viewsA: How to compare variables using Javascript?
You can make this type of checking simpler by using indexOf. first create a array as all the possibilities you want. ['1', '01', '08', '10', '12', '13'] After just check if the value you are looking…
-
3
votes2
answers111
viewsA: Javascript regular expression does not work within the form tag
I believe its purpose was to check the field before the form was sent. Note that you are working with events. Events relate to who fired it. In this case the correct use of the onkeyup input, as it…
-
1
votes2
answers864
viewsA: How to pick up space values in JSON
You can do this without problem through object, using document.createElement. var marcas = { "Marcas" : { "Acura": { "Modelos": ["Integra", "Legend", "NSX"] }, "Alfa Romeo" : { "Modelos": ["145",…
-
3
votes1
answer56
viewsA: Working with arrays and conditions
Like the @rray said you can do it, indexing beams: $_POST['campo_habilita'] = Array ( 0 => 'Habilitado', 1 => 'Habilitado', 2 => 'Habilitado', ); $_POST['campo_nome'] = Array ( 0 =>…
-
4
votes1
answer101
viewsA: Identify if and endif with regex?
In the test I performed the REGEX worked perfectly However I think it would be better to replace it with ~\[if([^\]]*)\]\s*?(.*?)\[\/if\]~s See working in REGEX 101. The big move is in modified s…
-
2
votes2
answers123
viewsA: How to make the parent relation between two select elements?
Instead of making ajax requests for each time you change the select, create all of them at once, and change the content available through a function. function changeChildren(value){ var select =…
-
1
votes2
answers699
viewsA: Regex Python Searching dates
mes = '07'; ano = '2016'; busca.find_all(string=re.compile("\d{2}\/%s\/%s\n\t\t\t\t\t\t\t\t" % (mes,ano), re.IGNORECASE)); Basically you generate a string with replacements to be made and compile…
-
3
votes2
answers228
viewsA: PHP - Return column sum at date specifies // PDO
To return the sum of a column you must use SUM in the query, however if you want to include other fields as well, you should group them through the GROUP BY. Example 1 SELECT SUM(p_line_l) FROM…
-
2
votes1
answer734
viewsA: How to recover unchecked checkbox values with PHP
simple, assemble a ternary: $checboxName = isset($_POST['name'])?true:false; if it exists then it was set, if not. EDIT In case you have many checkboxs and do not wish to check them all via ternary,…