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

I cannot get exactly 9 digits to pop in Adobe Acrobat using regEx.

Community Beginner ,
Mar 08, 2018 Mar 08, 2018

Copy link to clipboard

Copied

I cannot get exactly 9 digits to pop in Adobe Acrobat using RegEx custom redaction. Or any exact digit for that matter..

^[0-9]{9}$

-or-

^\d{9}$

returns zero hits.

Example = 456324787

This is simplest form and works in every online test and even on Regexbuddy.

I can get [0-9]{9} and \d{9} to pop but it gives a ton of false positives. Hence the ^ to start and $ to stop.

Example = 0.802738476(don’t want)

Example = 802738476.0(don’t want)

So is there any reason why Adobe pro redact would not accept the ^ or the $ to clean up my search??

I'm editing the SearchRedactPatterns.xml file to do this action.

TOPICS
Acrobat SDK and JavaScript , Windows

Views

543

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
LEGEND ,
Mar 08, 2018 Mar 08, 2018

Copy link to clipboard

Copied

Are these 9 digit numbers on a line by themselves because ^ is start of line and $ is end of line?

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 Beginner ,
Mar 08, 2018 Mar 08, 2018

Copy link to clipboard

Copied

intersting. Very good. So now I understand the ^ and the $ correctly.. I see now that they are reporting in line position.

So how would I search the pages and just report “exactly”

9 digits out on their own.

example=

837465738

-not-

00.637465839

637465839.00

So I guess this is closer to like some sort of trim or whitespace.?

My introduction to regex was yesterday so I’m learning. Knowing what I know now would it be:

(b\)\d{9}(b\)

Thank your for you help!

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 ,
Mar 08, 2018 Mar 08, 2018

Copy link to clipboard

Copied

It's "\b", not "b/". The escape character always comes before the escape letter.

Also, "^" and "$" do not signify the beginning and end of a line, but of a string. You can use a single RegExp to test a string that contains multiple lines in it. As mentioned, RegExps are an extremely complex subject, and sometimes a very frustrating one.

I don't think that "\b" will work for you. Try "\s", instead.

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
LEGEND ,
Mar 08, 2018 Mar 08, 2018

Copy link to clipboard

Copied

Regular expressions are a lifetime study and I’ve never got past the frustration phase. Not sure what you intend (b\) to do but beware of looking for word break characters since ”.” is, as well as a decimal point, very much a word separator. My instincts would be to look for a space specifically but these can be iffy in PDF. But then... looking for a space won’t match start of line. Ick.

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 Beginner ,
Mar 08, 2018 Mar 08, 2018

Copy link to clipboard

Copied

Noted.I was all over the road with the b and the \.

So the revised curiosity is how do I encapsulate just 9 numbers only?  Would I need a vert bar organize 2 searches?

It the attached view, how can I have it all and write a search that will not detect the value with the red arrow pointed at it.Capture.JPG

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 ,
Mar 08, 2018 Mar 08, 2018

Copy link to clipboard

Copied

Replace the first \b with \s, as well...

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 Beginner ,
Mar 08, 2018 Mar 08, 2018

Copy link to clipboard

Copied

If I do that the first no longer gets returned.

no whitespace there..

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 ,
Mar 08, 2018 Mar 08, 2018

Copy link to clipboard

Copied

You need to clearly define how you want it to work first. What should be allowed before (and after) the 9-digits, and what shouldn't be?

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 Beginner ,
Mar 08, 2018 Mar 08, 2018

Copy link to clipboard

Copied

Got it. Thank you! This thread has been very helpful!

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 ,
Mar 08, 2018 Mar 08, 2018

Copy link to clipboard

Copied

The best tool ever made for learning and testing GREP is… InDesign!

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 Beginner ,
Mar 09, 2018 Mar 09, 2018

Copy link to clipboard

Copied

Still have to check this out in SearchRedactPatterns.xml file but checks out everywhere else.

Contributed from a reddit user:

(?<!\d\.)\b\d{9}\b(?!\.\d)

https://regex101.com/r/Slf4eV/2

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 Beginner ,
Mar 10, 2018 Mar 10, 2018

Copy link to clipboard

Copied

This code matches any 9 digits exactly anywhere on a document using regex and online tools

1.Why is this expression not recognized when formatted into the SearchRedactPatterns.xml for Adobe Acrobat Pro Redaction?

2.Is there an equivalent that Adobe will understand?

(?<!\d\.)\b\d{9}\b(?!\.\d)

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 ,
Mar 12, 2018 Mar 12, 2018

Copy link to clipboard

Copied

LATEST

Hi ciliab5431014 ,

this one could come closer:

string.replace(/\d+\.\d+/g,"").replace(/\d{10,}/g,"").match(/\d{9}/g); // will return array or null

But keep in mind, that some cases are not caught by the pattern above leading to false positives or false negatives.

Some examples:

False positive with:

"My number is .123456789."

How to discern the case above from this one? :

"Just some words before I speak about a nine-digit number.123456789—numbers like that I want to catch. Oops, forgot a blank after my first sentence!"

And what, if the string contains a number in German notation where a , is used as a numeric decimal separator?
Or if separators are used for groups of digits.

Perhaps false negatives with:

"I want this: 123 456 789."

"I want this: 123,456,789."

German string: "I möchte das hier: 123.456.789, das hier aber nicht: 123.456.789,45."

Regards,
Uwe

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