"TV Shows\"balala wrote: ↑August 28th, 2022, 7:48 pm Sorry I thought you'll use the substitution ONLY for paths of files. My bad...
But now I'm not sure. For files I think my susbtitution does work. But what should it return for instance for the H:\Movies\TV Shows\ path? Sorry, but I didn't understand (my bad again)...
It is currently April 27th, 2024, 2:45 am
Another regexp question - how to get the folder name in a path?
-
- Posts: 1366
- Joined: September 7th, 2020, 2:24 pm
- Location: QLD, Australia
Re: Another regexp question - how to get the folder name in a path?
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
-
- Posts: 1366
- Joined: September 7th, 2020, 2:24 pm
- Location: QLD, Australia
Re: Another regexp question - how to get the folder name in a path?
The ini is also encoded with UTF-16 LE with Bom
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
-
- Posts: 518
- Joined: May 4th, 2020, 3:01 pm
- Location: Ankara, TURKEY
Re: Another regexp question - how to get the folder name in a path?
Code: Select all
Substitute="^.*\\(.*)(.).*":"\1\2"
It was my fault. I'm sorry for the confusion
You do not have the required permissions to view the files attached to this post.
I don't know where i going from here, but i promise it won't be boring...
-
- Rainmeter Sage
- Posts: 16174
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Another regexp question - how to get the folder name in a path?
I think you have to use a two step substitution. In the first step you'll remove the last backslash (if there is any). In the second substitution, you get the needed part of the path and add back the backslash (if you want). Try this option please: Substitute="^(.*)\\$":"\1","^(.*)\\(.*)$":"\2\" (see below why is colored red the last backslash).
As you probably figured it out, the first substitution ("^(.*)\\$":"\1") is executed only if the path ends with a backslash. In this case, that last backslash is removed.
The second substitution ("^(.*)\\(.*)$":"\2\") returns the needed folder name and adds back the backslash. If you want not to add the last backslash, just remove the last character of the substitution (the red colored above).
-
- Posts: 1366
- Joined: September 7th, 2020, 2:24 pm
- Location: QLD, Australia
Re: Another regexp question - how to get the folder name in a path?
Hey guys.
Sorry to present a frustratingly weird issue.
I seem to have found the solution, for me.
Substitute="^.*\\(.*)\\.*$":"\1\"
Now I am worried that this is a local issue with me, and the regexp will not work for other people.
Can you please test my solution?
Sorry to present a frustratingly weird issue.
I seem to have found the solution, for me.
Substitute="^.*\\(.*)\\.*$":"\1\"
Now I am worried that this is a local issue with me, and the regexp will not work for other people.
Can you please test my solution?
You do not have the required permissions to view the files attached to this post.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
-
- Posts: 518
- Joined: May 4th, 2020, 3:01 pm
- Location: Ankara, TURKEY
Re: Another regexp question - how to get the folder name in a path?
right, works fineCodeCode wrote: ↑August 28th, 2022, 8:25 pm Hey guys.
Sorry to present a frustratingly weird issue.
I seem to have found the solution, for me.
Substitute="^.*\\(.*)\\.*$":"\1\"
Now I am worried that this is a local issue with me, and the regexp will not work for other people.
Can you please test my solution?
Capture.PNG
Code: Select all
Substitute="^(.*)\\$":"\1", "^(.*)\\(.*)$":"\2\" ;<=== balala
Substitute="^.*\\(.*)\\.*$":"\1\" ;<=== you
Substitute="^.*\\(.*)(.).*":"\1\2" ;<=== me
I don't know where i going from here, but i promise it won't be boring...
-
- Posts: 1366
- Joined: September 7th, 2020, 2:24 pm
- Location: QLD, Australia
Re: Another regexp question - how to get the folder name in a path?
That is crazy!!tass_co wrote: ↑August 28th, 2022, 8:33 pm right, works fine
Code: Select all
Substitute="^(.*)\\$":"\1", "^(.*)\\(.*)$":"\2\" ;<=== balala Substitute="^.*\\(.*)\\.*$":"\1\" ;<=== you Substitute="^.*\\(.*)(.).*":"\1\2" ;<=== me
They all work.
Too cool...
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
-
- Rainmeter Sage
- Posts: 16174
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Another regexp question - how to get the folder name in a path?
One thing I have to add. The above substitution returns the name of the last folder in the path, if the path ends with a backslash, but returns the previous folder, if the path doesn't contain a backslash at the end. I tried to write my solution to work and return the last element in both cases. Definitely your solution is shorter, but are you absolutely positive there is no case when the last backslash is missing?
For instance for the H:\Movies\TV Shows\ path your solution returns TV Shows\, but for H:\Movies\TV Shows (no ending backslash), it returns Movies\
-
- Posts: 1366
- Joined: September 7th, 2020, 2:24 pm
- Location: QLD, Australia
Re: Another regexp question - how to get the folder name in a path?
Wow! Now that is awesome! Thanks for helping so much. In my view, balala's solution is the most versatile - since it allows for no backslash, yet provides it in the returned output.balala wrote: ↑August 28th, 2022, 8:53 pm One thing I have to add. The above substitution returns the name of the last folder in the path, if the path ends with a backslash, but returns the previous folder, if the path doesn't contain a backslash at the end. I tried to write my solution to work and return the last element in both cases. Definitely your solution is shorter, but are you absolutely positive there is no case when the last backslash is missing?
For instance for the H:\Movies\TV Shows\ path your solution returns TV Shows\, but for H:\Movies\TV Shows (no ending backslash), it returns Movies\
Perfecto!
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
-
- Rainmeter Sage
- Posts: 16174
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Another regexp question - how to get the folder name in a path?
Great! I'm glad.