1,939 questions
2
votes
1
answer
191
views
Regex find anything between + sign except \+ [duplicate]
With regex, I want to get anything between + sign avoid if + with backslash.
My string is GroupNo+ \+ +Name+ / +Ac
I want to get " \\+ " and " / " with php preg_matchall
I tried ...
2
votes
1
answer
97
views
PREG_MATCH_ALL not returning matches
I have a log file and trying to find instances of 2 consecutive lines.
Here is an extract of a file :
21:12:44 | Player "MinecraftNerd8" (DEAD) (id=630DB6BBFCCC2E66508D086E78D202BFA4FB1FB5 ...
4
votes
1
answer
315
views
Regular expression to match part of an optional part of a string [duplicate]
I have a string of words, here broken into lines to better visualize the repeating pattern:
Saint John eats less of those apples.
Saint Paul eats more of those berries.
Saint Luke eats those ...
0
votes
0
answers
31
views
match random lengths of string using regex (preg_match) [duplicate]
i have need to split string, by regex:
split digits together
split letters together
[ each part should contain between 3-5 chars RANDOMLY ]
so if i have:
'...
1
vote
0
answers
90
views
Trying to match any set of elements with a regex that have or whitespace [duplicate]
So I am currently using this regex, but I see a flaw in it for p and div tags:
(<(p?|div?)>).+(\s| )+(<\/(p?|div?)>)+
Given the current string:
<div class="blahblahblah ...
1
vote
1
answer
37
views
Regex: Match string with OR withour string delimiter
I'm extracting from bibtex and have a little problem, as the format can have values wrapped inside curly brackets OR NOT.
Please find the example text below:
@article{Roxas_2011, title={Social ...
0
votes
4
answers
230
views
Regex ignore specific string between two strings
So I have a string like this:
test //ita https://example.com lics// test // another // one
I can capture text between 2 "//" strings easy enough like so:
\/\/(.*?)\/\/
Which will return ...
0
votes
2
answers
117
views
Get substrings from text which start with one of an array of keywords and the substring must not include a second keyword
I want write some function that were accept two parameters $text and $keys. Keys that an array with keys.
At the output we need to get an array, where the keys will be the keys passed to the function (...
0
votes
0
answers
81
views
PHP: Get all valid domains and ip addresses from the string
So far I have used the preg_match_all function with various expressions, but I am not good at regex.
I have a string (downloaded html page). Of course, there are a lot of things on it. Including ...
1
vote
2
answers
151
views
Regex | PHP capture each illegal double quote in a json string
Given the following json string: {"key":"val"ue","other":"invalid ""quo"te"}
I want to capture each illegal double quote inside the values. ...
0
votes
3
answers
150
views
How do i scrape multiple lines in the sourcelist using cURL and preg_match_all
Hey im trying to webscrape a specific thing on a website, like this
<td><a href="javascript:void(0)" class="rankRow"
...
1
vote
1
answer
102
views
Retrieve pdf signature - preg_match_all() returns array with keys but which are empty
Based on this resource (PHP - how to get the signer(s) of a digitally signed PDF?) - I am trying to have a system in PHP that retrieves the digital signature of a file, so that later on I can verify ...
0
votes
3
answers
97
views
I want a regex pattern to grab text within a pattern that excludes matches followed by a particular string
I'm using preg_match_all() like this:
preg_match_all('/("user":"(.*?)".*?-->)/', $input_lines, $output_array);
On a string, the idea is that I want it to get whatever comes ...
0
votes
0
answers
32
views
preg_match_all and matching information between two characters [duplicate]
I am using preg_match_all in php to try to do some matching replacing and basic templating
My php match code is
preg_match_all( '/\{(.*?)\}/', $message, $match);
the content that is being passed in ...
1
vote
1
answer
35
views
How to get first preg match elements
I need with preg_match_all() to extract all [ANY_TEXT-pb] blocks.
My code:
$content = 'START Text1 [news-block] text2 [title1-pb] text3 text4 [title2-pb] text5 END';
preg_match_all('/\[(.*?)pb\]/si', $...
1
vote
1
answer
88
views
PHP regular expression to find "email":"[email protected]" pattern
I have a function that will find an email string that is in a specific format. I need to find this specific email string within the larger string. The specific email string I need to find has to be in ...
0
votes
0
answers
40
views
preg_match last characters after hyphen [duplicate]
Can anybody help me please. I get an url and need to take the last part after -.
Example data
game-when-no-one-at-xhU8c0dL
coins-at-the-desk-1xhz83c
example-example-1391340
Result needed
xhU8c0dL
...
0
votes
1
answer
100
views
Parsing Lisp-Like String into Tokens and Literal Text
Using the PHP v8 preg_match_all($Matches) function's "Match" parameter, I need to match a list of literal text and delimited tokens.
$x = preg_match_all($Regex, $Template, $Matches, ...
1
vote
1
answer
74
views
preg_match_all for dates with different format
I have a preg_match to get dates from a string:
preg_match_all('/\d{1,2}\.\d{1,2}\.\d{2,4}/',$myString,$dates);
This will get dates with the syntax:
01.01.2022
1.01.2022
1.1.2022
1.1.22
...
Now I ...
0
votes
0
answers
50
views
What pattern error is occurring in preg_match_all?
I have a piece of code (which I did not write) where a error is given when trying to call the pre_match_all function:
$pattern = "/([\w-:\*]*)(?:\#([\w-]+)|\.([\w-]+))?(?:\[@?(!?[\w-:]+)(?:([!*^$]...
0
votes
1
answer
68
views
preg_match_all is not working or showing result
{"popUp":false,"token":"NS2938f08ubjk765vhjJBKJB78vhjeec1_m1_7"}
This is curl response in JSON, and i want to extract token from this JSON response.
i used ...
0
votes
1
answer
119
views
PHP preg_match_all extract id and name, where id in tag is optional [duplicate]
I have following code:
<?php
$html = '<div>
<div class="block">
<div class="id">10</div>
<div class="name">first ...
0
votes
0
answers
16
views
regex - finding multiple occurances of a pattern and extracting a string [duplicate]
i have a code
<?php
$string='afdsfd data-win="3453453ASSS" some text data-win="3434534ASDDD" some more text data-win="1233RTYYY"';
preg_match_all('/data-win="([^&...
0
votes
0
answers
55
views
php split on each whitespace, but not after specific word to create array from string
Take this string:
$string = "wanted NOT IN OR"
preg_match_all('/\w+/', $string, $WordArray);
// outputs each word into array
But what if I do not want to split on the whitespace right ...
0
votes
0
answers
47
views
PHP regex to fetch the inner function list from JavaScript source code
Below is the JavaScript source code on which the php regex I am trying to apply.
<script>
function outerfunction () {
function abcd () {
return ('efgh', 1);
}
function efgh ...
1
vote
1
answer
54
views
solving if preg_match_all no output
I'm currently working on a script. The following code is included:
if(preg_match_all('!href="(\[^"\]+fref=fr_tab)"!',$contents,$aMatch))
This only applies if part of the link fref=fr-...
1
vote
2
answers
134
views
preg_match_all pattern from one array, subject from another
I have the following problem where I'm stuck for hours:
I have an array with my regex, where I want to match with the subject from another array.
Regex array:
Array
(
[tax] => /^(\S+\w)/
[...
1
vote
0
answers
65
views
Get a comma number from a string
I have a string like:
$string = "P 1 BNN-01 HV A7weg letsel (Auto) A7 Re 138,3 HASKERHORNE.";
I want to get the "138,3" part to use as variable like $number = "138,3". I ...
-5
votes
2
answers
78
views
PregMatch any of two phrases but not a third one
I have a list of links (that also have some svg icons in the a - it makes my pattern more complex, that's why I mention this), and I want to grab two particular ones.
So if this is the subject to ...
1
vote
1
answer
61
views
PHP Regexp with variable in string to search
I'm in need of a regexp that will allow me to retrieve all the following data from a php source file :
MUI('Some text')
MUI("Some text", $lang)
The regexp is used to extract all the terms ...
0
votes
1
answer
2k
views
Try to MatchAll a string in Power Apps
I've been programming in Power Apps for some time now (but I'm not a specialist). I'm trying to pass an array from Power Automate to Power Apps.
I was able to do that with a string and after a few ...
0
votes
1
answer
57
views
inserting multiple notationed preg_match_all element into mysql
I have variables gathered from another website with preg_match_all and echo the value. But the value is in $var1[0][n], n>0 form;I couldn't inserted the value into mysql.
Thanks for any help.
$path=...
-1
votes
2
answers
842
views
Extract text from multiple HTML tags [duplicate]
I am trying to make this work but I can't:
$str = "<html>1</html><html>2</html><html>3</html>";
$matches = array();
preg_match_all("(?<=<html&...
0
votes
2
answers
62
views
Regex with OR operator not catching "double" matches
Using PHP's preg_match_all I have the following problem.
Example string:
last_name, first_name
bjorge, philip
sdfsdf credit note dfsdf
kardashian, kim
mercury, freddie
Regex:
/\bcredit\b|\bcredit ...
-2
votes
1
answer
126
views
Regex to match non-empty string [duplicate]
Im trying to make preg_match_all regex that will work in next order. Group 1 to match "Example", Group 2 to match "[string]", Group 3 to match whitespace and "Number" and ...
2
votes
1
answer
57
views
Preg for checking how many time it occurs
Here I am having one preg
[-0-9a-zA-Z \/_:.,;=\'{0,2}"{0,2}\s]+$
With this I want to check lines whether they contains Alphabets, Numeric and some special character such as - _ , . ; ' " / =...
-1
votes
1
answer
53
views
Preg_match_all foreach to return comma separated strings [closed]
I have a text string and a list of words as key => word to match if any of the words are present in the string. If words are present, I would like to output a comma separated list of all the ...
0
votes
1
answer
65
views
preg_match() returning always empty arrays
I am still newbie so maybe it is simple but, I tried lot of things i found here and still cant get it right.
$patternPopis ='/(?:[^:|\d ])[A-Za-zÀ-ȕ .?+\d]+(?=\n)/i';
preg_match($patternPopis, $row, $...
1
vote
2
answers
86
views
Delete non number containing braces from string
A string may contain non-number in braces which needs to be deleted. Input can be multiline too, for example :
input:
# (1437)
# {19} (917) (1437)
# {19} (1437) [1449] [2474] [2098] [1351] [508] ...
0
votes
0
answers
17
views
PHP str_replace is not working with unicode variable content [duplicate]
I am working in PHP and I am trying to use str_replace in a text with unicode characters.
If I replace with this code, this works fine:
$message = str_replace($unicode_char, "\u{1F44B}", $...
0
votes
1
answer
73
views
Acessing values from preg_match_all in PHP 7.4
I am trying to access the values from the results of preg_match_all.
Below is my coding:
$strNbrOfPages = preg_match_all($strPattern,$strWorkDetails,$matches,PREG_OFFSET_CAPTURE);
Below is the ...
0
votes
2
answers
161
views
Batch search in php txt file
I want to search the ip addresses in the txt file. A single ip address shows the result when I log in, but when I type more than one ip address in the textarea, the result is not found. Can anyone ...
1
vote
1
answer
70
views
preg_match_all() returns only the last matches from a single row, but all matches from a multi-row string [duplicate]
I try to find all occurrences of a substring in text, using the preg_match_all() function:
<?php
$str = '<p>this <a href="https://api.slack.com/apps/" target="_blank&...
0
votes
1
answer
86
views
preg_match_all for atttach bbcode
I have two types of bbcode:
[attach]1234[/attach]
[attach=full]1234[/attach]
$message = 'this is message with attach [attach=full]1234[/attach]
I want to remove everything from string and using:
(...
2
votes
2
answers
69
views
Validate a string and return a dynamic number of isolated words
I would like to validate my input string and extract an unpredictable number of substrings from it -- with one regex pattern.
An example string:
location in [chambre, cuisine, salle-de-bain, jardin]
...
0
votes
1
answer
63
views
How to find all matches instead of the last match in look ahead and look behind in preg_match_all()
I have this text.
*s*
*q: what is 3+3? *.
*o: 3 *.
*o: 4 *.
*o: 6 *.
*e*
*s*
*q: what is 4*4? *.
*o: 7 *.
*o: 12 *.
*o: 16 *.
*e*
*s*
*q: what is 10/2? *.
*o: 1 *.
*o: 5 *.
*e*
I wrote the ...
0
votes
1
answer
81
views
Preg match all for extract name of function and parameter
I have this string:
not(matches(#[Sécurité][Alarme][Mode]#, ["Desarmer",{"action":"Desarmer Sys"}]), result).
And I want to extract the name of the function: not
And I ...
1
vote
2
answers
201
views
Match multiple lines of text with specific format
I am sending a few telnet cmds to a device and reading back its result values in a array.
I need to filter the data, but I'm not sure if preg_split() or preg_match() is better suited.
After isolating ...
0
votes
3
answers
106
views
Moving parts of {token} to the end of line based on condition
From a multiline input I want to move tokens if they're inside {} and match some number.
Sample input
# (811) (1485) [2756] {29} [555] {15}
# (811) (1476) {20} {15} (1485) [196] [2441]
# (911) (619) ...
0
votes
1
answer
175
views
how to use php preg_match_all() with overlap matches
I am trying (with no success) to get all possible matches with preg_match_all().
Any help would be greatly apreciated. Thank you in advance.
No related questions and answers clearly give a way to do ...