Questions tagged as 'preg-match'

1
answer

Can you optimize this code?

Can you optimize this code to make it faster? if (strpos($qt, "blood") !== FALSE){ if (preg_match("/^blood (?<blood>.+)$/", $qt, $match)){ switch ($match['blood']) { case "a+": $result = "A+"; $sndline = "Id...
asked by 13.05.2015 / 02:06
3
answers

How to check if there is a certain number in a php variable?

So I was giving a searched, looking for some function of php that verifies if a certain number exists inside a variable. And I found the preg_match (). code: $numeros = "1 2 3 4 5 6 7 8 9"; preg_match(1,$numeros); Error:   ...
asked by 25.01.2017 / 13:51
2
answers

Using REGEX in PHP to capture any number that is not within single quotes

I have been studying regex for some time and now I have a problem: Capturing all numbers, including decimals, that are not within single quotation marks . I'm creating a sort of viewer for PHP code to learn how to use regex better. I have...
asked by 19.12.2018 / 17:09
2
answers

Simple Quotes vs. Doubles in PHP Regex

Considering that I have a path which I want to check with preg_match if it is the desired path, what is the difference between the two following operations? // Single quoted string preg_match('/\/path\/to\/folder\//', $path) //...
asked by 18.10.2016 / 14:38
2
answers

preg_match (...) for various types of text

How can I validate the texts below? Letters (including accents) and numbers (without spacing), separated by. or,. ex: 'hello' Whole numbers and / or tenths. ex: '22' or '2.2'     
asked by 29.08.2016 / 11:48
1
answer

I can not search the words in brackets in php

I've created a function to check if some words exist in an array. I want to do the word search inside brackets "[]". Example: [as], [dar], [amar] ... For this, I'm using the preg_match () function to check if any of the words in the array exi...
asked by 28.08.2015 / 00:31
1
answer

How to create a function that validates if there is a MySQL function in a given string?

I am looking for a function that identifies (return true) if there is a MySQL function in a string. These would be some examples of possible input to function. <?php $randomstrings = [ "foo", //String comum "NOW()", //Função sem pa...
asked by 12.07.2017 / 17:25
1
answer

Simulate _GET php in string

I have a string to simulate: <li><a title="string" href="http://geting.com/?v=123?t=abc">Opção 1</a></li> I would like something that takes the parameter ?v= , just it, same as when we get the method $_GET["...
asked by 26.11.2018 / 20:54
2
answers

PHP: Get function argument with preg_match_all

Good afternoon: I'm picking up the value of calls to a particular PHP function straight from the source code. What I need is to scan each of the lines of the source code, and if there are one or more altext () function calls, get the argum...
asked by 19.06.2015 / 20:18
1
answer

Using preg_match

With this code I can block special characters in my input , however I want it to still accept . , - and _ how to proceed? elseif (!preg_match('/^[a-z A-Z0-9]+$/', $username)) { echo json_encode(array( 'log...
asked by 06.12.2017 / 17:24