[CS 5.5/JS/OSX] Simple regular expression crashes InDesign

I'm in the process of migrating a script from CS3 to CS5.5. When trying the script with no modifications it causes InDesign to stall, and I have to force close it. After running through the script line by line I found the culprit:
/A(_|-)?B\.jpg/.test("A-C.jpg")
This causes the entire script engine to freeze.
With CS3 it works fine. Also when do I slight change it works fine:
/A(-|_)?B\.jpg/.test("A-C.jpg")
Any idea what's going on? Is it a bug in the scripting engine?

Any ideas exactly what kind of expressions triggers the bug?
I rewrote my expression to not contain phrases like /(a|b|abc)?/. Instead I use /[ab]?(abc)?/, which is close enough, and seems to not trigger the bug.

Similar Messages

  • Help: Verify or Suggest a Simple Regular Expression

    I'm trying to do a mapping from a title to a file name portion of a URL. Thus the result needs to follow the rules as specified here:
    http://labs.apache.org/webarch/uri/rfc/rfc3986.html#unreserved
    I identified the following characters as legal: a-z / 0-9 / "-" / "." / "_" / "~"
    Everything else has to be converted to an underscore.
    I came up with the following expression:
    someString.replaceAll("[^a-zA-Z0-9-._~]", "_")Is that correct? I spent a lot of time trying to figure out regular expressions, but it seems like everyone (i.e. PHP, TextPad and now Java) has a slightly different version and to top it off, there not very good tutorials or explanations. I dread regular expressions!!!
    Can anyone help please?

    HoganWang wrote:
    Ur regular expression is right. The regular expression has simple and complex versions. If the replaceAll is frequently called, it is recommended to use Pattern to compile the regular expressions first.How does the expression know that the hypen isn't part of range? I guess the only way is that it is between alphabetical letters or numbers.
    In terms of efficiency. This is called once per page request i.e.
    somedomain.com/somecategory/title_title_title
    Well, I need to be able to translate title&title$title to title_title_title. It doesn't seem like a pre-compiling the regular expression will speed it up since between page requests, it won't remember fields or am I wrong?

  • Simple regular expression problem

    Hello,
    I need help with regular expressions. I have a situation when I need to get data from one table to another and I think my problem can be solved using REG EXP, but I don't know how to use them properly.
    I need to seperate varchar2 fileld whcih is basically number/number into 2 seperate number fields
    CREATE TABLE tst (CODE VARCHAR2(10));
    INSERT INTO tst VALUES('10/15');
    INSERT INTO tst VALUES('13/12');
    INSERT INTO tst VALUES('30');
    INSERT INTO tst VALUES('15');
    CREATE TABLE tst2 (po NUMBER, co NUMBER); I need to get code into co and po columns. I think result should look something like this, but:
    INSERT INTO tst2
    SELECT regexp_substr(CODE 'something here to get the number before /') AS po,
           regexpr_substr(CODE 'something here to get number after') AS co
    FROM tst;   Any help appreciated

    Hi Blu,
    Yes, I have tested with "0" in the figure (like 10/20 30/40). And it worked that time and then I replied. :) :)
    But Still it has a problem in pattern and rectified it below.
    Like :-
    SQL> select regexp_substr('10/40','[^/][0 9]',1,2) DD from dual;
    DD
    40
    But if I (The way you test) use a non zero value like 43 ; below query will not return 43.
    SQL> select regexp_substr('15/43','[^/][0 9]',1,2) DD from dual;
    DD
    My pattern has a slight mistake("-" missing between 0 and 9) and I changed and retested . Correct pattern - '[^/][0-9]' and now it will return 43..
    SQL> select regexp_substr('15/43','[^/][0-9]',1,2) dd from dual ;
    DD
    43this '[^/]+' pattern also works fine.
    Thank you for pointing out Blu; as I came to know lot more about patterns.
    Regards,
    Ashutosh

  • Simple Regular Expression Question

    Or ist it not so simple? Decide yourself:
    If a random text (lets say "Nader") does not contain for example the string "Bush", then it shall match the pattern. But how would that pattern look like?
    First I tried ^(Bush). But it doesn't work. Then I tried lots of other things and googling, with no success.
    Any ideas for that simple thing?

    Let me get this straight.
    Text area A will have some text in it. Let's say the user supplies "Bush".
    Right?
    Text area B is allowed to contain any text in it except an exact match of what is in text area A.
    Right?
    if (B.getText().equals(A.getText())) { // or however you get the string from a TextArea
      // Uh-oh! They match!
    }But it can't be that simple, else you woldn't have posted.
    So what are you looking for?
    Can A contain stuff that is to be interpreted as a regex? That is If A has "B.*sh" then B must not start with "B" and end with "sh"?
    Will either or both of them be line-based? That is:
    A:
    Bush
    Cheny
    B:
    Clinton
    Bush
    and no line from A must match any line from B?
    Maybe I'm just dense, but I still don't really understand what you're looking for, or why you need regex since you seem to be just looking for an exact string match. Initially you said "contain", which suggests " .* Bush .* " but later you seem to be talking about exact matches.

  • Simple regular expression in oracle query

    hi guys, I have this challenge.
    say I have a query:
    select name, user_name, object_type from questions;
    now, for the column object type, I can get values that end in 'Q' followed by number.
    So object type columns can be 00Q1, ABCQ2, 56Q7 e.t.c. It can be any number really.
    The thing is, I want to add a small grouping, so that for the rows which have the object type column ending in Q followed by number, I can have an additional column whose value changes to question.
    So the query now becomes:
    select name, user_name, object_type, column_type from questions;
    So column_type can be question if object type ends with Q and a number, otherwise just give it a default value, like Others or something.
    Is this possible and if so how can I please achieve it.
    Thanks very much.

    Hope this will help.
    SQL> with t as
      2  ( select '00Q1' element_name from dual union all
      3    select 'ABCQ2' from dual union all
      4    select '56QA7 ' from dual union all
      5    select '56Q7 ' from dual union all
      6    select 'ABCQA' from dual)
      7  select * from t
      8  where regexp_like(element_name,'\Q[0-9]')
      9  /
    ELEMEN
    00Q1
    ABCQ2
    56Q7Or something like this
    SQL> with t as
      2  ( select '00Q1' element_name from dual union all
      3    select 'ABCQ2' from dual union all
      4    select '56QA7 ' from dual union all
      5    select '56Q7 ' from dual union all
      6    select 'ABCQA' from dual)
      7  select t.*, DECODE(regexp_instr(element_name,'\Q[0-9]'),0,'Not Found',element_name ) comments
      8  from t
      9  /
    ELEMEN COMMENTS
    00Q1   00Q1
    ABCQ2  ABCQ2
    56QA7  Not Found
    56Q7   56Q7
    ABCQA  Not FoundEdited by: Saubhik on May 18, 2010 6:41 AM

  • A simple regular expression....

    What I need to do is find occurances of |A in a string, and replace it with another string. This sounds like a perfect use of the String.replaceAll() method! So, I gave it a try, and failed. The code String.replaceAll("|A", "ReplacedText"); doesnt actually replace |A. I was wondering if I need an escape character before the pipe or something since pipe I believe is used in regex logic. Thanks for any help in advance.

    You're right, you need to do:newString = oldString.replaceAll("\\|A", replacementText);...using the double backslash to ensure that a single backslash gets into the actual regex.

  • Simple Regular Expression

    I am not sure what is wrong with the code. As seen in the code below, I am checking the string to be a alpha numeric. So "#$%#%" checked for the pattern "[^a-zA-Z0-9]" should return true. I am not sure what is wrong.
    For the below code "Success" is returned.
    public class TestRE {
         public static void main(String[] args) {
              String str = "#$%#%";          
              if (str.matches("[^a-zA-Z0-9]"))
                   System.out.println("Failed");
              else
                   System.out.println("Success");
    }

    This regex would work only when all the characters are non alpha numeric. To check for any occurence of special character, we still need prefix .*? and suffix .* as
    if (str.matches(".*?[^a-zA-Z0-9]+.*"))or
    if (str.matches(".*?\\P{Alnum}+.*"))My understanding is that the regex is considering the whole string for the match. If there is any MISMATCH, then the condition fails.

  • Simple regular expression/perl/sed type question

    If I have a string like this:
    1. e4 c5 2. Nf3 Nc6 3. Bc4 e6 4. c3 Nge7 5. d4 d5
    and I want to put
    after ever third "word" (i.e., before 2., 3., 4., 5. ...)
    how do I do it?

    Find:
    s(d+.s)
    Replace:
    $1

  • Litte help with regular expression?

    Greetings all,
    I have a simple regular expression "(\\w+)\\s(\\w+)\\s(.+)"
    Which I want to match against the strings like "Acetobacter pasteurianus LMD22.1"
    But this always fails whenever there is a dot (.) character like "LMD22.1" in above string.
    How to solve this ?
    Thanks in advance.

    Shouldn't that be Acinetobacter?
    edit: nope, I'm wrong, you're right.
    Edited by: Encephalopathic on Apr 7, 2009 7:34 PM

  • Regular Expressions in CS5.5 - something is wrong

    Hello Everybody,
    Please correct me, but I think, I found a serious problem with regular Expressions in Indesign CS5.5 (and possibly in other apps from CS5.5).
    Let's start with simple example:
    var range = "a-a,a,a-a,a";
    var regEx = /(a+-a+|a+)(,(a+-a+|a+))*/;
    alert( "Match:" +regEx.test(range)+"\nLeftContext: "+RegExp.leftContext+"\nRightContext: "+RegExp.rightContext );
    What I expected was true match and the left  and the right context should be empty. In Indesign CS3 that is correct BUT NOT in CS5.5.
    In CS 5.5 it seems that the only first "a-a" is matched and the rest is return as the rightContext - looks like big change (if not parsing error in RegExp engine).
    Please correct me if I am wrong.
    The second example - how to freeze ID CS5.5:
    var range = "a-a,a,a-a,a";
    var regEx = /(a+-a+|a+)(,(a+-a+|a+)){8,}/;
    alert( "Match:" +regEx.test(range)+"\nLeftContext: "+RegExp.leftContext+"\nRightContext: "+RegExp.rightContext );
    As you can see it differs only with the {8,} part instead of *
    Run it in CS5.5 and you will see that the ID hangs (in CS3 of course it runs flawlessly}.
    The third example - how to freeze ID 5.5 in one line (I posted it earlier in Photoshop forum because similiar problem was called earlier):
    alert((/(n|s)? /gmi).test('s') );
    As you can guess - it freezes the CS5.5 (CS3 passes the test).
    Please correct me if I am doing something wrong or it's the problem of Adobe.
    Best regards,
    Daniel Brylak

    Hi Daniel,
    Thanks for sharing. Really annoying indeed.
    Just to complete your diagnosis, what you describe about CS.5 is the same in CS5, while CS4 behaves as CS3.
    var range = "aaaaa";
    var regEx = /(a+-a+|a+)(,(a+-a+|a+))*/;
    alert([
        "Match:" +regEx.test(range),
        "LeftContext: "+RegExp.leftContext.toSource(),        // => CS3/4: EMPTY -- CS5+: EMPTY
        "RightContext: "+RegExp.rightContext.toSource()        // => CS3/4: EMPTY -- CS5+: ",a,a-a,a"
        ].join('\r'));
    So there is a serious implementation problem of the RegExp object from ExtendScript CS5.
    I don't think it's related to the greedy modes. By default, JS RegExp quantifiers are greedy, and /a*/ still entirely captures "aaaaaa" in CS5+.
    By the way, you can make any quantifier non-greedy by adding ? after the quantifier, e.g.: /a*?/, /a+?/, etc.
    I guess that Adobe ExtendScript has a generic issue in updating the RegExp.lastIndex property in certain contexts—see http://forums.adobe.com/message/3719879#3719879 —which could explain several bugs such as the Negative Class bug —see http://forums.adobe.com/message/3510078#3510078 — or the problems you are mentioning today.
    @+
    Marc

  • Regular Expressions and String

    How do I return a String array as follow using regular expression.
    String[] strArray = {"Now is the time", "you can optionally preview your post","message by using a number of special tokens."}
    from this string
    <separator>Now is the time</separator><separator>you can optionally preview your post</separator><separator>message by using a number of special tokens.</separator>
    Note: The string has the <separator> XML tag

    How do I return a String array as follow using regular
    expression.
    String[] strArray = {"Now is the time", "you can
    optionally preview your post","message by using a
    number of special tokens."}
    from this string
    <separator>Now is the time</separator><separator>you
    can optionally preview your
    post</separator><separator>message by using a number
    of special tokens.</separator>
    Note: The string has the <separator> XML tag
    This cannot be done using simple regular expressions - at least not if your number of <separator>s is random, which is what you seem to imply.
    Simple regular expressions are one-off, that means it can have a String array as a result, but only to the amount of brackets in the regex.
    a regex like:
    <separator>([^<]*)</separator><separator>([^<]*)</separator><separator>([^<]*)</separator>
    would return what you want, but I doubt that it is as flexible as you want it to be.

  • Regular express excludes an integer

    Does some one know if there is a simple regular expression pattern which can be used in an XML schema as a restriction to exclude a few integers from the entire integer set?
    For example, if I want to use the schema to validate an xml document which has an element called 'playerId' and its value can be any integers BUT 1000, the schema segment for the validation could be like:
    <xsd:restriction base="xsd:integer">
    <xsd:pattern value="<<pattern string>>"/>
    </xsd:restriction>
    what <<pattern string>> can I use to validate the value IS NOT 1000?
    I tried a few such as ((\d*)-(1000)), [^(1000)], \d*[^(1000)], none worked. Any help will be greatly appreciated.

    Why don't you derive from an integer type instead of a string? I know this seems ridiculously verbose for such a simple restriction, but it should do what you want:<xsd:attribute name="root">
      <xsd:simpleType>
        <xsd:union>
          <xsd:simpleType>
            <xsd:restriction base="xsd:nonNegativeInteger">
              <xsd:maxInclusive value="999"/>
            </xsd:restriction>
          </xsd:simpleType>
          <xsd:simpleType>
            <xsd:restriction base="xsd:positiveInteger">
              <xsd:minInclusive value="1001"/>
            </xsd:restriction>
          </xsd:simpleType>
        </xsd:union>
      </xsd:simpleType>
    </xsd:attribute>

  • Regular expression does not execute runtime

    Hello adobe collegue's,
    I am currently stumbling on a strange issue regarding javascript embedded to compress a string:
    // main function to compress any string, removing all non-word characters and making the string all lowercase
    function compressString(input){
        var patt=new RegExp("\\W","g");
        patt.compile(patt);
        var output = input.toLowerCase().replace(patt,"")+"YESS";
        return output;
    Somehow this code does execute perfectly while previewing in adobe designer 9.0.0.2 but runtime all javascript does execute except for the part mentioned above.
    I know this part is executed because in the result i see the string "YESS" added to the response of this function.
    Somehow the pattern is not compiled, or executed runtime...
    I also tried more simple regular expressions but none of them actually worked.
    For the templates the option client is set where to execute the javascript, although while testing the options to solve the issue is also tried settings both and server. None provided the solution.
    Can someone provide any help...it's appreciated!
    Thanks,
    Marcel

    Hi,
    you can make your function more simple.
    function compressString(input){
              return input.toLowerCase().replace(/\W/g,"") + "YESS";

  • DOM Parser fails with regular expression using anchor (carat, dollar)

    I'm using version "Oracle XDK Java 9.0.4.0.0 Production"
    In trying to parse XML against schema: a regular expression fails to parse the data "8:00" with the following simple regular expression: "^.*$" (used to narrow the error)
    The error message is
    <Line 14, Column 25>: XSD-2025: (Error) Invalid text '8:00' in element: 'XYZ'
    If I remove the anchors and just have ".*", the data is parsed successfully.
    I dont understand why the parse fails when I use a anchors in the regular expression, and the java Pattern/Matcher classes succeed with the anchors?

    That "ns670" string is an xml namespace prefix. it should have a corresponding xml namespace declaration somewhere in the xml document (i'm guessing you have not shown the whole document). the actual value of an xml namespace prefix is meaningless. if you parse the xml with a namespace aware DOM parser, it should generate Nodes with the correct namespace. the namespace is the value you care about when extracting data from the document, not the namespace prefix.
    alternately, if you parse the document using a namespace aware DOM parser, you can just look for nodes based on their "local" name (the part after the ":" separator) and ignore the namespace/prefix.
    whatever you do, please do not parse the xml with a regex, see this http://stackoverflow.com/a/1732454/552759 for details (applies to xml as well).

  • Simple question about regular expressions

    Hi,
    Using Java's regular expression syntax, what is the correct pattern string to detect strings like the following :-
    AnnnnnA
    where A = a single (fixed) alphabetic character and
    n = at least one but possibly many digits [0-9].
    Example strings to be searched :-
    A45A (this should match)
    A3A (this should match)
    A3446655577A (this should match)
    A hello world A (this should NOT match as no digits are present between the A's).
    Thanks.

    A least one digit "A.*\\d.*A"
    Only digits "A\\d+A"

Maybe you are looking for

  • Please Fix This Bug - Mac Version CS4

    Mac OS 10.6.3 (bug has been around a while) Mac Pro Flash CS4 10.0.2.566 Open up Flash using the Designer workspace (it can be any workspace, though). Now select Import so the OS X file dialog appears. Drag the dialog to be longer vertically so you c

  • Database connectivity issues since upgrading to 2011

    I have several reports that were created in CR 2008.  Since upgrading to 2011, none of them connect to the SQL server when I try to refresh the data.  The error message says invalid logon.  I can get the reports to refresh if I follow this process: 1

  • Clean installation of system 7.1 on Macintosh SE/30 ?

    Could someone please advise  how to do a clean installation of System 7.1 on my old Macintosh SE/30 ? It used to run 6.0.5, I have done an upgrade to 7.1 , but I think I have somehow messed it up. For instance , the Apple menu is empty. It still boot

  • BW query: Quotation - Sales - Billing Overview?

    Dear all, We are looking for an overview report which shows the flow from the quotation documents + item, sales documents + item and the Billing documents + item. In this flow we would like to see the document numbers themselves, the throughput times

  • Urgent help - Cannot open examsoft app in Mac (Yosemite)

    I need to use examsoft and downloaded and installed to my Mac (OXS Yosemite), but I could not open it. Whenever I am trying to open it, it just pops out in the dock and then quit immediately. What should I do? Thank you!