This question already has answers here:
What special characters must be escaped in regular expressions?
(13 answers)
Closed 5 years ago.
I 've a File structure "solution/"
Need a reg exp to match all the files under "solution/" Excluding .img files in the path "solution/tree/changes/sample.img"
I tried below it but of not worked
^solution\/tree\/changes\/((?!.img).)*$
Thanks in advance
You did not mention language, but this should work
^solution\/tree\/changes\/(?!.*\.img).*$
see regex101 demo: https://regex101.com/r/Y7znBy/1
Important! You need to set multilineflag
#Fallenhero My Exact requirement is I 've following file structure
solution/moon/
solution/tree/anomoly/
solution/tree/enquiry/
solution/tree/changes/space.img
solution/tree/changes/mine.txt
I've to parse a json file as input with regular expression to copy all the files in the above structure except solution/tree/changes/space.img
JSON Input which I've tried but didn't work
"^solution\/(?!tree\/).*\/*",
"^solution\/tree\/(?!changes\/).*\/*",
"^solution\/tree\/changes\/((?!.img).)*$"
Could you please provide your ideas
Related
This question already has answers here:
How to use regex to get file extension?
(3 answers)
Closed 6 months ago.
We have a custom field defined in data studio which extracts and returns the file extension from a string in this case it is from the event label.
I have been using the below with some success
REGEXP_EXTRACT(Event Label, '\\.([\\w\\.-]+)$')
However I'm finding if the string contains multiple periods its including that aswell
Eg it's also extracting text like
07.21.pdf
7.22.PDF
07.21.docx
docx.pdf
How can I tweak my regex to only include from the last period and ignore any earlier.
You could try replacing [\\w\\.-] with [^\\.]
\\.([^\\.]+)$
[^\\.] will match everything except for ., so the match will not be able to contain dots inside.
The full formula would look like this:
REGEXP_EXTRACT(Event Label, '\\.([^\\.]+)$')
This question already has answers here:
How to edit all lines in Visual Studio Code
(9 answers)
Closed 3 years ago.
So essentially someone on our dev team made a bit of a big issue where they had changed all of the build actions on .csproj files and we are thinking of the easiest way to change them back.
We want to use regex to open all the csproj files via VSCode. The format to open multiple files in file explorer is
"filename" "filename1" "filename2"
my list is
com.Console.job1.csproj
com.Console.job2.csproj
com.Console.job3.csproj
com.Console.job4.csproj
my current regex
(.+)\n
then my regex to replace is
"$1"\s
which doesnt work at all
You can use this regex :
To locate pattern
([^\s]+)(\n)?
To replace :
"$1"
keep in mind the replace pattern contains a space at its end
Demo :
Here
This question already has answers here:
Find numbers after specific text in a string with RegEx
(3 answers)
Closed 3 years ago.
I have string like this which looks like a url
mainpath/path2/abc/PI 6/j
From the string I need to get the number along with PI
Main problem is the position of PI part wont be always the same. Sometimes it could be at the end. Sometimes at the middle.
So how can I get that number extracted using regex?
I'm really stucked with this
It's as simple as using the RegEx Tool. A Regular Expression of /PI (\d+) and the Output Method of "Parse" should do the trick.
If you're using Alteryx... suppose your field name is [s] and you're looking for [f] (in your example the value of [f] is "PI")... then you could have a Formula tool that first finds /PI by first creating a new field [tmp] as:
SubString([s],FindString([s],"/"+[f])+1)
and then creating the field you're after [target]:
SubString([tmp],0,FindString([tmp],"/"))
From there run [target] through a "Text to Columns" tool to split on the space, which will give you "PI" and "6".
This question already has answers here:
Extended regular expressions (ERE) for .gitignore
(2 answers)
Closed 8 years ago.
I am using git in my project. My home directory contain few files like
Title v2.12.12.exe
Title v1.4.21.exe
Title v3.42.11.exe
All these starts with Title v and ends with .exe and contains some version in the middle. What changed should I made in .gitignore to ignore these types of file?
Just tried it and the simplest seem to work:
Title v*.exe
The only caveat is that you may catch more than expected like "Title v-not.a.valid.version.exe"
This question already has answers here:
Using regular expressions to parse HTML: why not?
(18 answers)
Closed 8 years ago.
Can anyone give me the pattern of the regex to get all the local images ONLY. :(
I'm using the code below but it includes the image links.
Regex rgx = new Regex("[^\\/:*?\"<>|]+\\.(?i)(jpg|png|gif|bmp)", RegexOptions.IgnoreCase);
input:
http://dl9.glitter-graphics.net/pub/846/846279rr8zhg26y6.gif
images/strawberries.jpg
output:
846279rr8zhg26y6.gif
strawberries.jpg
I don't want the 846279rr8zhg26y6.gif
If your input strings are bounded somehow (e.g. inside ""s or at the start of the input string) then things are easier, and if the input has a semantic context of being a (relative or absolute) URL, and you only want relative URLs, then easier still.
I would however note that the extension part should probably be jpe?g rather than just jpg and I do wish people would never ever use a bmp on a webpage!