Posts by Pedro Corso • 563 points
16 posts
-
3
votes1
answer87
viewsA: Regex
Whereas valid values only have numbers, you need only search for the existence of non-digits (\D) within that tag: <endnum>.*?\D.*?<\/endnum>. Then just put the tags in capture groups:…
-
7
votes1
answer717
viewsA: Separating a paragraph by sentences
Solution (Ecmascript 2018 / ES9): .*?[.!?](?![.!?])(?<!\b\w\w.) Demonstration: var paragrafo = "Sou Dr. José. Meu passatempo é assistir séries. Adoro animais!! E você?"; var frases =…
-
1
votes1
answer98
viewsA: setTimeout with each loop does not work
The setTimeout does not keep the variable these according to the value it contained at the time it was called. It will always pick up the current reference. At the end of the first ten seconds, the…
-
0
votes1
answer342
viewsA: Row number in table
In his data-element you’re putting the class .informacoes as parameter. Your toggle will act on this selector and will display all class elements .informacoes. Another way to get the tag <tr>…
-
1
votes2
answers45
viewsA: Get Radio and Text Values in Order
If you use the Jquery selector, it already gets the elements for you in the order they are in HTML. In this particular case, you could do the following: $("input[type='text'],…
-
3
votes1
answer359
viewsA: Regex - Remove between tag and class name start and last tag close
Although we know very well which is the classic answer for people trying to process HTML using regular expressions, we also have the next answer in the same question, which adds an interesting…
-
2
votes1
answer501
viewsA: Which code has the highest cost? (Bubblesort in C)
In the iterative case, you calculated correctly. From what I understand in the comments, you want to evaluate the asymptotic complexity of your algorithms. Asymptotic complexity analysis deals only…
canswered Pedro Corso 563 -
2
votes2
answers1526
viewsA: Ignore any white space in the middle of a string
Or you can remove any space first and perform the search afterwards: texto = re.sub("\s", "", texto) You can then search for the text normally using its regular expression. Depending on your goals,…
-
1
votes1
answer477
viewsA: Search and view objects items nested with Javascript
Your problem can be solved with recursion: var categories = [ { code: 1, name: "papelaria", children: [ { code: 12, name: "papel", parentCode: 1, children: [] }, { code: 13, name: "lapis",…
-
0
votes1
answer36
viewsA: Doubt with regular expression, data from a url
Regular expression: .*?-(.+?)-?_.* Testing: https://regex101.com/r/frWvgd/1
-
2
votes4
answers2929
viewsA: How do I capitalize the first letter?
Regular expressions also work, and it only takes one line to solve the problem. The other two are just to take the value of the text box and then to reset its value:…
-
1
votes2
answers4211
viewsA: Passing parameter through URL
From what I understand from your description, it seems that the object window can do it for you: var link = "" // Seu link aqui. var newWindow = window.open(link, "_blank"); newWindow.paramTeste =…
-
4
votes2
answers697
viewsA: Regular expression supporting at least two of the four conditions
This one works: ^(?!^([a-z]+|[A-Z]+|\d+|[\W_]+)$).{4,20}$ Testing: https://regex101.com/r/G4v9oy/7 When entering the site, in the right panel, a detailed explanation about regex is also offered.…
-
1
votes1
answer45
viewsA: Scroll up after changing view
Will what you want to do is this: window.scrollTo(0, 0)? According to that answer: https://stackoverflow.com/a/15007296/6882194 I think you can use: $scope.$on('$locationChangeSuccess',…
-
0
votes2
answers887
viewsA: How to insert text at cursor position?
It doesn’t work because as soon as you click out of the editor, you lose the focus in the element and the cursor disappears, and so you get the default position 0. This way, every time you click on…
-
3
votes4
answers1418
viewsA: How to format result with comma and dot?
One simple regular expression solves your problem: var numero = "4189.00"; numero = numero.replace(/(\d{1,3}|\G\d{3})(?=(?:\d{3})+(?!\d))/g, "$1,"); Upshot: "4,189.00" This regular expression works…
javascriptanswered Pedro Corso 563