[Solved] Preg_match on multiline text

The idea is to avoid the issue of new lines by not using the dot ($subject is your string): $pattern = ‘~ Project\hNo\.\h\d++\hDATE\h (?<date>\d{1,2}\/\d{1,2}\/\d{1,2}) \s++No\.\hQUESTION\hANSWER\s++ (?<No>\d++)\s++ # all characters but D or D not followed by “ate Required” (?<desc>(?>[^D]++|D(?!ate\hRequired))+) \D++ (?<date_required>\d{1,2}\/\d{1,2}\/\d{1,2}) ~x’; preg_match_all($pattern, $subject, $matches, PREG_SET_ORDER); print_r($matches); Note that i use possessive quantifiers and atomic … Read more

[Solved] How to get attribute of href on the basis of selected text? [closed]

Try this : put id for anchor tag <a id=”anchor1″ href=”https://stackoverflow.com/questions/25931155/site.com/register.php?mid=username&mode=bn&bid=1″> use below javascript <script> var href = document.getElementById(‘anchor1’).href; //get index of ? var indexStart = href.indexOf(‘?’); var indexLast = href.length; //get href from ? upto total length var params = href.substring(indexStart+1, indexLast); //get tokens with seperator as ‘&’ and iterate it var paramsArray = … Read more

[Solved] How to strip parts of the given url using preg_replace (php) [closed]

For this specific case, you don’t need a regular expression, you can just parse the url $url=”http://dev.time.com/wp-content/uploads/2014/08/sheep-shrek-300×199.jpg?w=360″; $parts = parse_url($url); echo $parts[‘host’] . $parts[‘path’]; Missed that you want to strip the size … $data = preg_replace(‘/(-\d+x\d+)\.jpg/’, ‘.jpg’, $data); 1 solved How to strip parts of the given url using preg_replace (php) [closed]

[Solved] Preg_match for a string key

The regex would be this: /^[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}$/ Regex explanation: Start regex expression /^ Capital A-Z and Numerical 0-9 [A-Z0-9] 5 long exactly {5} Dash between sets End expression $/ <?php $reg = ‘/^[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}$/’; $string = ‘YTMG3-N6DKC-DKB77-7M9GH-8HVX7’; preg_match($reg, $string, $matches, PREG_OFFSET_CAPTURE); print_r($matches); ?> 7 solved Preg_match for a string key

[Solved] What does this regular expression maens “/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/” [duplicate]

What this big regex commands mean? Pattern #1 Breakdown: / #start of pattern delimiter (@.*@) #Capture Group #1: match an @ sign, then zero or more (as many as possible) of any non-newline character, then another @ sign | #or (\.\.) #Capture Group #2: match a literal dot, then another literal dot | #or (@\.) … Read more

[Solved] More than one preg_match queries? [closed]

if(preg_match($fullname_pattern,$fullname)) Remove Last “)” And add here (preg_match($password_pattern,$password))) Like this: if(preg_match($fullname_pattern,$fullname) && preg_match($email_pattern,$email) && preg_match($password_pattern,$password) ) { 1 solved More than one preg_match queries? [closed]