RegEx swap positions of elements in filename [closed] - regex

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
I am using LameXP to convert and encode audio files. These files are grouped poorly, but contain info in their filenames that could be used for this. Examples of files are as follows.
Genji-00000005818F.0B2-He'll talk.ogg
Tracer-00000005818C.0B2-Do you think Maximilien will talk_.ogg
Tracer-00000005818E.0B2-What does that mean_.ogg
Winston-00000005818D.0B2-He just deals with the money.ogg
LameXP offers a renaming tool that utilizes RegEx for find and replace. I would like to move the file ID (0000000XXXXX) to the beginning before the character name. What expression would I use to isolate the data ID and move it to the front?
Ideally, files would end up like this:
00000005818F_Genji-He'll talk.ogg

You need to provide more infomation that how the file name is formatted.
According to the examples you provided, this should do the trick:
Regex
^(.+?)-([0-9A-F]+)\.[0-9A-F]+-
^ Start of the string
(.+?) Any characters, as few as possible, use this to capture author name, and put it in group 1
- A dash
([0-9A-F]+) Any hexidecimal characters, put it in group 2
\. A dot
[0-9A-F]+ Another cascade of hexidecimal characters, use this to capture 0B2
- A dash
Substitution
\2_\1-
Check the test cases

Related

Extract the required part from same type of URLs in notepad+++ by 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 11 months ago.
Improve this question
I have a list of URLs from same website. How can I extract a particular part of them using regex in Notepad++?
Here is a part of the URLs:
https://www.example.in/example/MT60B2G8HB-48BA-TR?qs=iLbezkQI%252BsgqYFd1yfooJw%3D%3D
https://www.example.in/example/AT25L128A-MHE-T?qs=IS%252B4QmGtzzoXQyQfwYv36A%3D%3D
Output should be MT60B2G8HB-48BA-TR & AT25L128A-MHE-T from all the similar type of URLs.
A short alternative as usual
Find:^.*/(.*?)\?.*
Replace with:$1
If all URLs have the same url, path up until the last part & do always have GET-parameters (using ?), then you can use this:
"(?<=https://www.example.in/example/)[^?]+"
# match any string that has https://www.example.in/example/ before it until the first ?
If it is optional whether the url has GET-params:
"(?<=https://www.example.in/example/)[^?\s]+"
# match any string that has https://www.example.in/example/ before it until the first ? or whitespace/linebreak
the following will allow you to search for the pattern (in regex mode of course) :
(?<=https://www.example.in/example/).*(?=\?)
(?<=...) is called positive lookbehind and must be a fixed pattern positioned before what you are looking for
(?=...) is called positive lookahead and must be a fixed pattern positioned after what you are looking for (here the first '?' escaped with '\')
If you want to replace the pattern then you can simplify to this.
Find what : https://www.example.in/example/(.*)\?.*
Replace with : $1

Akeneo attribute regex wir OR "|" not working [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 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.

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:

Using regular expressions to locate line comments without spaces [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 tried to find all comments beginning with // that don't have a space after the slashes.
I want to select only the slashes. No whitespace or text before that, no whitespace or text after that.
So far I've reached to [\s].(\/\/(?! )) but it catches the space before the slashes as well.
Basically I wanna make sure my line comments have a space after the slashes.
I'm trying to do this either in JavaScript or in any text editor.
Since javascript doesn't have the lookbehind feature, you can't.
The workaround (for instance, in a replacement context) is to use a capture group for the character before the two slashes and to start the replacement string with a reference to this group ('$1replacement'):
([^/\s]|^)//(?! )
You can use the following regex:
.*(\/\/(?= )) demo
The idea is to use positive lookahead and capture the // iff it is followed by a space.
EDIT: Just noticed that your question is contradictory. So if you want to capture if the // is not followed by a space, use this: .*(\/\/(?=\S)). Otherwise use the one above.