Questions tagged [regex]
Denotes questions related to Regular expressions(regex) being used in magento
27
questions
0
votes
1
answer
35
views
Regular Expression - remove quotes from HTML attributes that does not contain spaces but keep quotes around URLs
I'm trying to simplify HTML and JS for my page, and have problem with regular expression:
$replace = [
...,
'~([\r\n\t ])?([a-zA-Z0-9]+)="([a-zA-Z0-9_/\\-]+)"([\r\n\t ])?~s' => '$1$2=$...
0
votes
1
answer
47
views
Regex to read log
Still struggling with that regex to read logs
This is the regex I made so far
/^(?<date>(\[|)(\d{4}-\d{2}-\d{2}(T| )\d{2}:\d{2}:\d{2}(\]|.+\d{2}:\d{2}\]|.+\d{2}:\d{2})))(?<message>.*?)$/gm
...
0
votes
1
answer
31
views
Issue with regexp to retrieve log messages
I'm having a little issue with regexp, i know this isn't directly a magento issue though.
My goal is to get a sub printing of magento logs in the admin.
To do so, I've created the following method
...
2
votes
1
answer
894
views
Js regex for UAE Mobile Number
Validate UAE mobile number using js regex.
Mobile No- +971 XXXXXXXXX (+971 and 9 digits after it.)
0
votes
1
answer
235
views
Magento 2 : Allow special character at the end in password
I want to allow special character at the end of string, something like Test123@. I have used the following regex. Can anyone help me how can i acheive it
[^a-zA-Z0-9]
Thanks
1
vote
0
answers
194
views
How modify html output
I need to modify html output.
I'm using afterGetOutput method in plugin for Magento \ Framework \ View \ LayoutInterface.
But the method is calling only before FPC creating. But I need to change ...
0
votes
1
answer
89
views
How to detect the page handle in my observer?
I want to avoid the execution of my observer in case the page handle contains checkout or catalog, how could I do it?
0
votes
1
answer
3k
views
How to build a regex to capture the contents between DIV?
This is my test input string
Test code <div>Testing here. Div contents</div> Blah Blah <div>Second div</div>Blah
I need to capture the contents between . Please help me ...
1
vote
2
answers
3k
views
How to Validate Special Characters in Magento 2 Validation Mixin
I want to validate special characters in a custom validation mixin file (validation-mixin.js)
When I am using this validation mixin for my input field, i.e. a Purchase Order Number in checkout, it ...
0
votes
1
answer
228
views
RegEx validation in M1 (Magento 1.9.4) for eav attribute_code in extension does not work
I have an extension where customer attributes are created (magento 1.9.4).
except for the validation of the passed variable, the extension works fine.
in the controller there is a regex-test.
...
1
vote
1
answer
676
views
How to Validate Comma Seprated Values in Admin Configuration
I want to Add Validation of Comma Separated Values in Admin Configurations
I Know How to Add Custom Validation Using Js is just need the Regex (Regular Expression)
2
votes
2
answers
1k
views
What does this pattern match when filtering strings for URLs
What exactly is this line for
preg_replace('#[^0-9a-z]+#i', '-', parent::filter($string))
in the following method in \vendor\magento\framework\Filter\TranslitUrl.php:
public function filter($string)...
0
votes
1
answer
171
views
Regex for starting with character and rest all are digits
I want a regex of length 13 in which starting word is a alphabet and rest 12 entries are digit. Something like this : A123456789764
0
votes
1
answer
293
views
What is % in regular expression "%^/(test)-(.*?)-(.*?)$%"?
I am doing magento2 developer training. I am working on exercise"Create a new router which “understands” URLs like /frontNameactionPath-
action and converts them to /frontName/actionPath/action". In ...
0
votes
1
answer
800
views
Need to extend credit-card-type.js for master card detection and add new/latest regex pattern(resolved by myself)
Need to extend credit-card-type.js for add master card detection new/latest pattern:
I am creating and extending payment method using this link http://inchoo.net/magento-2/implementing-payment-...
1
vote
1
answer
5k
views
Magento 2 - How to use pattern validation
I'm using a plugin to validate the street field (based on https://magento.stackexchange.com/a/158101/28803) and I want to use the validation method 'pattern' to test for the following regex:
.*[0-9].*...
1
vote
2
answers
1k
views
RegEx in PHP file
I would like to place a RegEx Code in PHP code to validate a password. Example below of current code:
if (strlen($password) && !Zend_Validate::is($password, 'StringLength', array(6))) {
$...
0
votes
1
answer
44
views
Quantity adjustments for en_IN locale websites
When adjusting quantity on the product page or cart page to any quantity, Zend Framework isNumber() function fails to validate the number for numbers passed through in an en_IN locale website. As a ...
2
votes
4
answers
534
views
how to display desktop theme on tablets, ipads?
I have used the following matched expression for mobile devices..
iPhone|iPod|BlackBerry|Palm|Googlebot-Mobile|Mobile|mobile|mobi|Windows Mobile|Safari Mobile|Android|Opera Mini
Now mobile ...
0
votes
1
answer
476
views
Minicart items count update
I'm using this extension:
Ajax Cart Popup
It works fine, but there is a problem of updating items counter which renders together with mini cart icon in the header.
With original developers help on ...
4
votes
1
answer
365
views
SUPEE6788 APPSEC-1063 SQL Injection
I've been looking around and haven't found any definitive heuristics to detect whether or not a code-base is affected, so I've resorted to performing a recursive file scan that matches a list of ...
1
vote
1
answer
961
views
Adding multiple rewrites to config.xml
I'm trying to add a few url rewrites into the config.xml file in the "app/etc/" folder.
I am not using the url rewrite function in magento itself because in need to be able to use regex.
I tried the ...
1
vote
1
answer
2k
views
Can I use Regex in the URL Redirect section in Magentos backend?
Can I use Regex in the URL Redirect section in Magentos backend? Or any wildcards?
Thanks
0
votes
2
answers
82
views
Regex to Capture Text Between Rounded Bracket
Im having trouble to create the regex pattern (javascript) to capture the text between rounded bracket. Hereby the string value:
var pattern = /->__\(([^)]+)\)/g;
var value = "Line 54:'label' =>...
9
votes
3
answers
2k
views
Problem with Data URIs and CSS File Merge
Magento CSS file merge is pretending the hostname to my data-uris because the RegEx in Mage_Core_Model_Design_Package (beforeMergeCss) does not work as expected. It should prepend hostname to relative ...
1
vote
1
answer
199
views
Magento custom cache clear by regex
Is it possible in Magento to allow for cache to be cleared in a custom code by using regular expression to target cache tags?
The scenario I have is I am know of a list of cache tags I will be ...
0
votes
2
answers
98
views
Analyse existing codebase for localization readiness
I have a recollection of seeing a tool or script that could analyse a legacy Magento project (custom theme and modules) to check for non-i18n code.
The concept of a regex to find strings that are ...