• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Illustrator :: Find the Word

Explorer ,
Nov 18, 2022 Nov 18, 2022

Copy link to clipboard

Copied

Hi All,

 

I’m relatively new at this. I’m making a script for a Illustrator file that has the words “New-Man”, “NewMan”, “New Man”, “New – Man”, etc.

 

The word “New-Man” is the right format so I need to find the remaining scenarios like “NewMan”, “New Man”, “New – Man”, etc. and write a error report in a excel file.

 

Please can any one help me to find this.

 

Thanks in advance!

TOPICS
Scripting

Views

746

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , Nov 18, 2022 Nov 18, 2022

Hi pixxxel, I will not disagree with the regex king 🙂

Votes

Translate

Translate
Community Expert , Nov 18, 2022 Nov 18, 2022

Really? Is he here, too? And I thought we were alone.
😉

Votes

Translate

Translate
Adobe
Community Expert ,
Nov 18, 2022 Nov 18, 2022

Copy link to clipboard

Copied

this snippet finds all variations

 

var str = 'Im making a script for a Illustrator file that has the words “New-Man”, “NewMan”, “New Man”, “New – Man”, etc.'

var matches = str.match(/New.*?Man/g);
if (matches) {
    for (var a=0; a<matches.length; a++) {
        $.writeln(matches[a]);
    }
}
New-Man
NewMan
New Man
New – Man
Result: undefined

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 18, 2022 Nov 18, 2022

Copy link to clipboard

Copied

Hi Carlos,

nice snippet.

🙂

 

How about a little expansion? 

 

var str = 'Im making a script for a Illustrator file that has the words “New-Man”, “NewMan”, “New Man”, “New – Man”, “new – Man”, “New – man”,  “new – man”,etc.'

var matches = str.match(/[Nn]ew.*?[Mm]an/g);
if (matches) {
    for (var a=0; a<matches.length; a++) {
        $.writeln(matches[a]);
    }
}
New-Man
NewMan
New Man
New – Man
new – Man
New – man
new – man
Result: undefined

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 18, 2022 Nov 18, 2022

Copy link to clipboard

Copied

Hi pixxxel, I will not disagree with the regex king 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 18, 2022 Nov 18, 2022

Copy link to clipboard

Copied

Really? Is he here, too? And I thought we were alone.
😉

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 20, 2022 Nov 20, 2022

Copy link to clipboard

Copied

LATEST

Its working fine, thank you so much.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines