Akeneo attribute regex wir OR "|" not working [closed] - regex

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
This post was edited and submitted for review 1 year ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
The problem in Akeneo seems to be that simple regex combinations not working. I think the functionality (a single or group regex combination) is not integrated/implemented proper in Akeneo. If there is anybody out there who knows a trick to do a regex combination please let me know.
Tried to figure out how to make regex with | OR working in Akeneo "attributes".
the simple Example not working either a syntax error or no matching in Akeneo:
find this "323"
or find "123456"
\d{3}|\d{6}
Can anybody help?

According to the documentation, you need to use regex literal notation, and anchor the match both at the start and end of the string (so, add a grouping):
/^(\d{6}|\d{3})$/
Here, / are regex delimiters, ^ matches the start of string, (...) is a capturing group that contains two alternatives, six digits or three digits, and then end of string anchor, $, follows.

Related

Negate the output of the regex pattern [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed last year.
Improve this question
I want to negate the outcome of the regex pattern, so that it should return everything except the regex outcome.
Sample String:
SMTP:test.abc#xyz.com;smtp:test.123#xyz.biz;sip:test.123#xyz.biz
I have written a below regex which gives output as- test.abc#xyz.com
(?<=SMTP:)(.*?)(?=;)
Now i want everything except the above outcome i.e
SMTP:;smtp:test.abc#xyz.biz;sip:test.abc#xyz.biz
I am trying to negate but it is not working.
Any help is much appreciated.
It might be overcomplicated, but if you need multiline matching and a smtp account can be in the beginning of a line, this:
(SMTP:)|(;[^(SMTP)]*)|(^[^(SMTP)]*)
would match:
SMTP:
anything after a ; up until another SMTP
anything at the beginning of a line (no need of ;) up until another SMTP
Have a look at some tests here.
This can break down if an email name contains SMTP in it, but I hope you won t have any.
Another approach is use your matching regex, (?<=\SMTP:)(.*?)(?=\;), and keep deleting what it matches from the string.

How to remove certain prefix using regex [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
My User data can come in any of the following 3 ways -
user="dc\AAA", user="BBB", user=CCCC,
Now, the bottom two I am able to extract it easily but issue comes when user data has an additional prefix of "dc" to it
I am trying to remove that prefix using regex and format all user data in single regex as below, but the unable to do so
user=AAA user=BBB user=CCC
Can someone please help.
This regex should do the work: (?:.*\\)?(.*).
Let's split this regex into parts:
(?: ) - A non-capturing group
.*\\ - Any characters many times, trailing by backslash
? (after the brackets) indicates the data in the brackets may occur once or not at all
(.*) Any characters
Overall - Capturing the data after the backslash if exists
I suggest using this amazing website for trying regex

Match a word from a link [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I'm trying to work with regex but I'm still not capable of. Asking for your help!
I have links like these:
https://open.spotify.com/track/1Q07lxRM6aQJYtRFzQUtwu?si=LrEcPs3pSxaznY2GLH4V8Q
https://open.spotify.com/album/7lyxArCeA4kkHRiYpnh8eA
open.spotify.com/artist/1mBlZPMpRL8wT9aHBnBBph
I'd like to match the "artist" part in the last link. How can I do it? I thought about using slashes as "separator" than get the string from there but I have no idea.
Assuming you want to extract the top directory name following the
domain name, how about:
import re
url = 'open.spotify.com/artist/1mBlZPMpRL8wT9aHBnBBph'
m = re.search(r'(?:https?://)?[^/]+/([^/]+)', url, re.IGNORECASE)
if m:
print(m.group(1))
Output:
artist
Below, I'm using Python.
It's just build a case insensitive regex that advance any chars (.) with +(1 or more chars) and than use a prefix that occurs always before artist link artist/, finally use ()s to group. Inside ()s uses a class for letters and digits with + suffix (1 or more chars)
.+artist/([a-z1-9]+)
The replaced string it just
/1
The details vary a little bit according to the programming language adopted
See here:

Very simple regex not finding my search text [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have this regex string:
("prodcssstart.*prodcssend","xx")
and my file like this:
prodcssstart
<!--<link href="content/bundles/css.min.css" rel="stylesheet" />-->
prodcssend
But when I run it then it fails to find the expression.
Can someone suggest what I might be doing wrong, I've simplified it so much but I am thinking maybe there is a problem with the .* that I use to match everything. Any help would be much appreciated.
First of all, you can't parse HTML with regex.
But in your case the problem is most likely caused by newlines, because by default the dot doesn't match the newline. You need to pass the proper switch to disable this (e.g. re.DOTALL in Python and s in Perl).
You could come up with a tempered greedy token solution:
prodcssstart
(?:(?!prodcssend).)*
prodcssend
Breakdown:
look for prodcssstart
match any character as long as it is not followed by prodcssend
match prodcssend
See a demo on regex101.com (mind the different modifiers!).

Regular expression for negativenumbers (123.456,789-) [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I'm searching for a pattern for matching numbers with hyphen at the end like this :
125,000-
1.234,567-
60,000-
Just try with following regex:
/\d[.,\d]*-/
Or even:
/\d([.,]?\d+)*-/
NOTE Aleš Krajník's answer is basically the same as the answer I finally came to, except that his uses non-capturing grouping (as captures are not required)... he should get the votes IMHO as he was first
Note that in the following answer I'm assuming that , comma is the decimal separator, and that the . point is the thousands separator (eg for European numbering).
I believe the following is "correct":
^\d{1,3}(.\d{3})*(,\d+)?-$
This matches eg:
1-
12-
123-
123.456-
123.456.789-
1,0-
1,01-
1,001-
1,0001-
123.456,01-
123.456.789,0001-
etc
But will not match eg
1234-
123,-
123.4-
123.1,001-
123.45-
1..1..1-
1.1.1-
1,1,1-
.,-
etc.
The exact regex should read: \d{1,3}(?:\.\d{3})*(?:,\d+)?-
Try something like this:
[0-9.,]+-
\d{1,3}(?:[,]\d{3})*- takes internationalisation into account. The one below allows strings like 1..9 to match, which really should not.