Copy link to clipboard
Copied
For example, my script name has two cases:
Rename Links with Caption behind 【@】 characters.jsx
Rename Links with Caption behind 【】characters.jsx
The key character of the first one is @, the second one is empty
Now I want to get the characters between【】.
If there is content in 【】, get it, if it is empty, get empty("").
Thank you very much.
Copy link to clipboard
Copied
Hi @dublove how about this...
var scriptName = decodeURI(File($.fileName).name);
var matcher = /【([^】]+)】/;
var match = scriptName.match(matcher);
if (!match)
alert('There was no brackets in script name.');
else if (0 === match[1].length)
alert('There was no text inside the brackets.');
else if (match[1] === '@')
alert('There was "@" inside the brackets.')
else if (match[1][0] === '@')
alert('There was "@" and "' + match[1].slice(1) + '" inside the brackets.')
else
alert('Text inside brackets = "' + match[1] + '"');
(For anyone else reading this note that the OP's filename includes lenticular brackets.)
- Mark
P.S. please just use the one tag "Scripting" to your posts like this. Do not add other tags "Bug", "Feature Request" etc. unless it is actually about those things.
Edit 2025-06-22: added a couple more options to the checking of match.
Copy link to clipboard
Copied
You can't get it straight?
Doesn't seem to support that:
var matcher = /(?<=【)([^】]+)(?=】)/;
I used a
if (match[1] === "@")
Hint: Can I really not humanly use a reserved character when it is illegal to use it in the following cases?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
wait for...me
Copy link to clipboard
Copied
if (match[1] === '@')
@ Reserved characters, Tip: Prohibition of use
Find more inspiration, events, and resources on the new Adobe Community
Explore Now