Regular expression - get longest number from string

I believe it is easy one but I can't get it.Lets say I have a string 'A1_1000' I want to substract the 1000 using regular expression. When I feed Match regular expression I get '1' which is not the longest number. I know other ways of doing that but I want clean solution in one step. Does anybody knows the right regular expression to accomplish that? Thanks!
LV 2011, Win7
Solved!
Go to Solution.

ceties wrote:
This is the best solution I was able to come with. I am just wondering if there is "smoother way" without the cycle.
Since multiple checks are required I would tend to beieve that we do have to loop through the possibilities. in this example
I start check at offset "0" into the string for a number. Provided i find a number I check if it is longer that any previous number I found and if so save the new longer number in the shift register.
Have fun!
Ben
Message Edited by Ben on 04-15-2009 09:23 AM
Ben Rayner
I am currently active on.. MainStream Preppers
Rayner's Ridge is under construction
Attachments:
Find_Longest.PNG ‏33 KB

Similar Messages

  • How to specify ");" as a regular expression in split method of String class

    How to specify ");" as a regular expression in split method of String class using delimeters?

    Sorry, you can't specify that by using delimiters. Mostly because this requirement makes no sense.
    Do you rather need "\\);"?

  • FM to get Personel Number from USER ID

    Hi,
       Is there any FM to get Personel Number from the USER ID(sy-uname).
    Thank you,
    Ramu N.

    Hi Ramu,
    You can find the user-id & Personnel Number in the table PA0105.
    select single PERNR from pa0105 into PERSONEELSNUMMER
    where usrid eq USER_ID
    and   endda eq '99991231'.
    hope this helps!
    best regards,
    Thangesh

  • Get number from string

    Hi,
    I have a problem with an select.
    I need to compare two string columns. First column includes only a number with 9 characters:
    '001234567'
    Second column includes text where somewhere inside this text is the number 001234567.
    'Hallo1 001234567'
    I need to extract the 9 character big number out of the string. I thought using the regular expression feature could help me.
    SELECT
      REPLACE(REGEXP_REPLACE('hallo 001122334', '[a-z]', ''),' ') "REGEXP_REPLACE"
    FROM dual;But this would exclude the number 1 after Hallo:
    Result: '1001234567'
    The number I look for is always 9 character long.
    Thanks ahead,
    Tobias

    You have many variants:
    with your_table as
         (select
                'hallo1001122334' first_column,
                '001122334' second_column
          from dual
    select *
    from your_table
    where
    --1) regexp_like(first_column,'.*'||second_column||'$')
    --2) first_column like '%'||second_column
    --3) regexp_substr(first_column,'\d{9}$')=second_column
    --4) regexp_replace(first_column,'\D','') like '%'||second_columnFourth variant - includes case when chars can be between numbers in first column (for example 'hallo100a1a1a2a2a3a3a4').

  • Regular expression - parse version number string

    Hi,
    I try to parse a string using regular expressions but id did not work correctly in all cases.
    The string that i want to parse can have one of the following layout:
    3.4.5.v20090305 or
    3.4.5The first three parts have to be integer values, the last part can be a free string (which is optional).
    I use the following code to parse the version number and extract the parts:
    Pattern versionPattern = Pattern.compile("(\\d+)\\.{1}(\\d+)\\.{1}(\\d+)(?:\\.{1}(\\w+))?");
    Matcher m = versionPattern.matcher(versionString);
    if (!m.find()) {
        throw new IllegalArgumentException("Version must be in form <major>.<minor>.<micro>.<qualifier>");
    // assert that we matched every part
    // three groups (without qualifier) or four parts (with qualifier)
    int groups = m.groupCount();
    if (groups != 4) {
         throw new IllegalArgumentException("Version must be in form <major>.<minor>.<micro>.<qualifier>");
    // extract the parts
    major = parseInt(m.group(1));
    minor = parseInt(m.group(2));
    micro = parseInt(m.group(3));
    qualifier = m.group(4);The above regular expression works in all cases that i tested, except one.
    The follwoing string is accepted as correct input: (but it shouldn't)
    3.4.5a.v20090305And i get the result:
    major = 3
    minor = 4
    micro = 5
    qualifier = a.v20090305
    Thanks for help or suggestions :)
    Best Regards,
    Michael

    heissm wrote:
    Hi,
    I try to parse a string using regular expressions but id did not work correctly in all cases.
    The string that i want to parse can have one of the following layout:
    3.4.5.v20090305 or
    3.4.5The first three parts have to be integer values, the last part can be a free string (which is optional).
    I use the following code to parse the version number and extract the parts:
    Pattern versionPattern = Pattern.compile("(\\d+)\\.{1}(\\d+)\\.{1}(\\d+)(?:\\.{1}(\\w+))?");
    Matcher m = versionPattern.matcher(versionString);
    if (!m.find()) {
    throw new IllegalArgumentException("Version must be in form <major>.<minor>.<micro>.<qualifier>");
    // assert that we matched every part
    // three groups (without qualifier) or four parts (with qualifier)
    int groups = m.groupCount();
    if (groups != 4) {
    throw new IllegalArgumentException("Version must be in form <major>.<minor>.<micro>.<qualifier>");
    // extract the parts
    major = parseInt(m.group(1));
    minor = parseInt(m.group(2));
    micro = parseInt(m.group(3));
    qualifier = m.group(4);The above regular expression works in all cases that i tested, except one.
    The follwoing string is accepted as correct input: (but it shouldn't)
    3.4.5a.v20090305And i get the result:
    major = 3
    minor = 4
    micro = 5
    qualifier = a.v20090305No, that can't be the output. Perhaps you have some old class files you're executing, because with the code you now posted, that can't be the result.
    To verify this, execute this:
    import java.util.regex.*;
    public class Main {
        public static void main(String[] args) {
            String versionString = "3.4.5a.v20090305";
            Pattern versionPattern = Pattern.compile("(\\d+)\\.{1}(\\d+)\\.{1}(\\d+)(?:\\.{1}(\\w+))?");
            Matcher m = versionPattern.matcher(versionString);
            if (!m.find()) {
                throw new IllegalArgumentException("Version must be in form <major>.<minor>.<micro>.<qualifier>");
            // assert that we matched every part
            // three groups (without qualifier) or four parts (with qualifier)
            int groups = m.groupCount();
            if (groups != 4) {
                 throw new IllegalArgumentException("Version must be in form <major>.<minor>.<micro>.<qualifier>");
            // extract the parts
            System.out.println("1 -> "+m.group(1));
            System.out.println("2 -> "+m.group(2));
            System.out.println("3 -> "+m.group(3));
            System.out.println("4 -> "+m.group(4));
    }and you'll see that the following is the result:
    1 -> 3
    2 -> 4
    3 -> 5
    4 -> nullSome remarks about your pattern:
    "(\\d+)\\.{1}(\\d+)\\.{1}(\\d+)(?:\\.{1}(\\w+))?"All the "{1}" can be omitted they don't add anything to your regex and are only cluttering it up. And you'll probably also want to "anchor" your regex using the start- and end-of-string-meta-characters, like this:
    "^(\\d+)\\.(\\d+)\\.(\\d+)(?:\\.(\\w+))?$"

  • Cannot get regular expression to return true in String.matches()

    Hi,
    My String that I'm attempting to match a regular expression against is: value=='ORIG')
    My regular expression is: value=='ORIG'\\) The double backslashes are included as a delimiter for ')' which is a regular expression special character
    However, when I call the String.matches() method for this regular expression it returns false. Where am I going wrong?
    Thanks.

    The string doesn't contain what you think it contains, or you made a mistake in your implementation.
    public class Bar {
       public static void main(final String... args) {
          final String s = "value=='ORIG')";
          System.out.println(s.matches("value=='ORIG'\\)")); // Prints "true"
    }

  • OR ('|') in regular expressions (e.g. split a String into lines)

    Which match gets used when you use OR ('|') to specify multiple possible matches in a regex, and there are multiple matches among the supplied patterns? The first one (in the order written) which matches? Or the one which matches the most characters?
    To make this concrete, suppose that you want to split a String into lines, where the line delimiters are the same as the [line terminators used by Java regex|http://java.sun.com/javase/6/docs/api/java/util/regex/Pattern.html#lt] :
         A newline (line feed) character ('\n'),
         A carriage-return character followed immediately by a newline character ("\r\n"),
         A standalone carriage-return character ('\r'),
         A next-line character ('\u0085'),
         A line-separator character ('\u2028'), or
         A paragraph-separator character ('\u2029)
    This problem has [been considered before|http://forums.sun.com/thread.jspa?forumID=4&threadID=464846] .
    If we ignore the idiotic microsoft two char \r\n sequence, then no problem; the Java code would be:
    String[] lines = s.split("[\\n\\r\\u0085\\u2028\\u2029]");How do we add support for \r\n? If we try
    String[] lines = s.split("[\\n\\r\\u0085\\u2028\\u2029]|\\r\\n");which pattern of the compound (OR) regex gets used if both match? The
    [\\n\\r\\u0085\\u2028\\u2029]or the
    \\r\\n?
    For instance, if the above code is called when
    s = "a\r\nb";and if the first pattern
    [\\n\\r\\u0085\\u2028\\u2029]is used for the match when the \r is encountered, then the tokens will be
    "a", "", "b"
    because there is an empty String between the \r and following \n. On the other hand, if the rule is use the pattern which matches the most characters, then the
    \\r\\n
    pattern will match that entire \r\n and the tokens will be
    "a", "b"
    which is what you want.
    On my particular box, using jdk 1.6.0_17, if I run this code
    String s = "a\r\nb";
    String[] lines = s.split("[\\n\\r\\u0085\\u2028\\u2029]|\\r\\n");
    System.out.print(lines.length + " lines: ");
    for (String line : lines) System.out.print(" \"" + line + "\"");
    System.out.println();
    if (true) return;the answer that I get is
    3 lines:  "a" "" "b"So it seems like the first listed pattern is used, if it matches.
    Therefore, to get the desired behavior, it seems like I should use
    "\\r\\n|[\\n\\r\\u0085\\u2028\\u2029]"instead as the pattern, since that will ensure that the 2 char sequence is first tried for matches. Indeed, if change the above code to use this pattern, it generates the desired output
    2 lines:  "a" "b"But what has me worried is that I cannot find any documentation concerning this "first pattern of an OR" rule. This means that maybe the Java regex engine could change in the future, which is worrisome.
    The only bulletproof way that I know of to do line splitting is the complicated regex
    "(?:(?<=\\r)\\n)" + "|" + "(?:\\r(?!\\n))" + "|" + "(?:\\r\\n)" + "|" + "\\u0085" + "|" + "\\u2028" + "|" + "\\u2029"Here, I use negative lookbehind and lookahead in the first two patterns to guarantee that they never match on the end or start of a \r\n, but only on isolated \n and \r chars. Thus, no matter which order the patterns above are applied by the regex engine, it will work correctly. I also used non-capturing groups
    (?:X)
    to avoid memory wastage (since I am only interested in grouping, and not capturing).
    Is the above complicated regex the only reliable way to do line splitting?

    bbatman wrote:
    Which match gets used when you use OR ('|') to specify multiple possible matches in a regex, and there are multiple matches among the supplied patterns? The first one (in the order written) which matches? Or the one which matches the most characters?
    The longest match wins, normally. Except for alternation (or) as can be read from the innocent sentence
    The Pattern engine performs traditional NFA-based matching with ordered alternation as occurs in Perl 5.
    in the javadocs. More information can be found in Friedl's book, the relevant page of which google books shows at
    [http://books.google.de/books?id=GX3w_18-JegC&pg=PA175&lpg=PA175&dq=regular+expression+%22ordered+alternation%22&source=bl&ots=PHqgNmlnM-&sig=OcDjANZKl0VpJY0igVxkQ3LXplg&hl=de&ei=Dcg7S43NIcSi_AbX-83EDQ&sa=X&oi=book_result&ct=result&resnum=1&ved=0CA0Q6AEwAA#v=onepage&q=&f=false|http://books.google.de/books?id=GX3w_18-JegC&pg=PA175&lpg=PA175&dq=regular+expression+%22ordered+alternation%22&source=bl&ots=PHqgNmlnM-&sig=OcDjANZKl0VpJY0igVxkQ3LXplg&hl=de&ei=Dcg7S43NIcSi_AbX-83EDQ&sa=X&oi=book_result&ct=result&resnum=1&ved=0CA0Q6AEwAA#v=onepage&q=&f=false]
    If this link does not survive, search google for
    regular expression "ordered alternation"
    My first hit went right into Friedl's book.
    Harald.

  • Getting a number from  (char)System.in.read

    I am very new to java so please forgive the seemingly basic question.
    When I try to simply get a number for input into a program, and I use (char)Sysytem.in.read(),
    it only gives me the acutual Keyboard number (ie.. 2 = 50, 1 = 49).
    Even when I try to parse an Integer using :
    public static void getNum( ) throws NumberFormatException
         char char1;
         String String1 = new String ("");
         int X;
         char1 = (char)System.in.read();
    while ( char1 <= '0' && char1 <= '9' )      
         String1 = String1 + char1;
         char1 = (char)System.in.read();
         X = Integer.parseInt(String1);
    System.in.read();
         return X;
         System.out.println(X);
    This gives me a usable number but if I try to use a decimal point in the number and convert it to a double, it wont work because the decimal wont read into the (char)System.in.read();
    Anyone have a suggestion ?

    Hope this helps - although haven't tried out your code.
    System.in.read() returns the next byte of information in the buffer, if the buffer is empty it'll prompt for input (passing control back to hardware/OS). Say the user types 10.56 and presses return - now the buffer has the information 10.56 plus a LF(line-feed) and and a CR(carriage return) character (this is how it is from DOS anyway) and control is passed back to your program which gets only the first byte of information from the buffer, which in this case would represent the character '1', only it doesnt get back the character '1', it gets an int type which represents the byte of information which represented the character '1' to your hardware/OS system (which I believe is decided by the machine local encoding system).
    By casting this int to a char by the expression
    (char) System.in.read()
    its converted to the original character that the int represented from the buffer
    If you were using System.in.read() only you would have to reconstruct the input as a String by concatenating the char's one by one only ignoring the last 2 bytes of the buffer (which captured the LF and CR).
    Say you had the resulting String from the above reconstruction in the variable s1,
    you could then attempt to convert the resulting String to a floating-point type (say a double) using
    d = Double.parseDouble(s1)
    where d was a double type (as mentioned by abnormal)
    You'd have to put this in a try/catch statement because the user could type something invalid like 10.6a5
    which would cause the parseDouble() method to throw an exception which unless you handle it yourself will cause your program to abend with a NumberFormatException.
    This all seems to be a lot of hard work for input apparently so simple, which is why abnormal suggest using a BufferedReader to overcome the problem of 'manually' stripping the CR and LF from the input leaving you with just a String. I must admit I'm not sure of why abnormal's code wouldn't work for you. But I thought I'd post this anyway because you might find the background info helpful.

  • How can I get some text from string like AB_CD_9.9.9_Sometext

    How Can I get
    only 9.9.9 from  string "AB_CD_9.9.9_Sometext" with powershell and regular expression?
    Thank you,
    Lei

    This works.
    if('AB_CD_9.9.9_Sometext' -match '\d\.\d\.\d'){$matches[0]}else{'notfound'}
    ¯\_(ツ)_/¯

  • Regular Expression to Check number with at least one decimal point

    Hi,
    I would like to use the REGEX_LIKE to check a number with up to two digits and at least one decimal point:
    Ex.
    10.1
    1.1
    1
    12
    This is what I have so far. Any help would be appreciated. Thanks.
    if regexp_like(v_expr, '^(\d{0,2})+(\.[0-9]{1})?$') t

    Hi,
    Whenever you have a question, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002
    SammyStyles wrote:
    Hi,
    I would like to use the REGEX_LIKE to check a number with up to two digits and at least one decimal point:
    Ex.
    10.1
    1.1
    1
    12
    This is what I have so far. Any help would be appreciated. Thanks.
    if regexp_like(v_expr, '^(\d{0,2})+(\.[0-9]{1})?$') t
    Do you really mean "up to two digits", that is, 3 or more digits is unacceptable?  What if there are 0 digits?  (0 is less than 2.)
    Do you really mean "at least one decimal point", that is, 2, 3, 4 or more decimal points are okay?  Include some examples when you post the sample data and results.
    It might be more efficient without regular expressions.  For example
    WHERE   TRANSLATE ( str              -- nothing except digits and dots
                      , 'A.0123456789'
                      , 'A'
                      )   IS NULL
    AND     str           LIKE '%.%'     -- at least 1 dot
    AND     LENGTH ( REPLACE ( str       -- up to 2 digits
                    )     <= 2

  • Get IDoc-number from flat IDoc using dynamic configuration

    Dear experts
    In an IDoc2File scenario I have added the IDoc-number to dynamic configuration using the folling code in an UDF:
    DynamicConfiguration conf = (DynamicConfiguration)
    container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey FileName = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/File","DOCNUM");
    conf.put(FileName, a);
    The information is stored in the SOAP message
    <SAP:DynamicConfiguration SOAP:mustUnderstand="1">
      <SAP:Record namespace="http://sap.com/xi/XI/System/File" name="DOCNUM">0000000000012345</SAP:Record>
    </SAP:DynamicConfiguration>
    Can anybody tell me how I can access this information in the "variable substitution" section of the CC? Perhaps something like "message:docnum"?
    Additional information:
    Taking the IDoc-number from the payload using e.g. "payload:ORDERS05,1,IDOC,1,EDI_DC40,1,DOCNUM,1" does not work, since the XML-IDoc has been converted to an flat-IDoc.
    Thanks in advance for any good ideas
    Markus

    Dear Rodrigo and Sarvesh
    Thanks for your help so far! I applied your hints and now it is working fine.
    But now I have the following additional questions
    1.) My message mapping only maps the input IDoc to an output IDoc of the same type and structure. The MM is only required to process the UDF. Is there another, better solution to achieve my requirement that the IDoc-number shall be part of the filename?
    2.) In the CC you have the possibility to use temporary files (section "Processing", Option "Put File" = "Use Temporary File". I think this will not work with the given solution, will it?
    To possibly help somebody else or clarify the mechanism once again, I wrote down how my solution now looks like.
    My UDF in the message-mapping looks like this
    - Input = DOCNUM of IDoc, e.g. ORDERS05/IDOC/EDIDC/DOCNUM
    - Outpt = DOCNUM of IDoc, e.g. ORDERS05/IDOC/EDIDC/DOCNUM
    - UDF:
    public String putDynamicConfiguration(String docnum, Container container) throws StreamTransformationException{
    try
         DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
         DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
         String filename = "Prefix_" + docnum + ".txt";
         conf.put(key, filename);
         return docnum;
    catch (Exception e)
         return docnum;
    In the CC the settings are now as follows
    File Name Scheme = . -> only a dot or something else, because this field is obligatory, even if it is not used in this case.
    Variable substitution (...)
        Enable -> unchecked
    Adapter-Specific Message Attributes
        Use Adapter-Specific Message Attributes -> checked
        Fail If Adapter-Specific Message Attributes Missing -> checked
        File Name -> checked
        Directory, File Type, Temporary Name Scheme for Target File Name -> unchecked
    When I send an IDoc to PI and view the Adapte-Engine Version of the message (the SOAP-document, not the payload) I can find the Filename:
    <SAP:DynamicConfiguration SOAP:mustUnderstand="1">
    <SAP:Record namespace="http://sap.com/xi/XI/System/File" name="FileName">Prefix_0000000000012345.txt</SAP:Record>
    </SAP:DynamicConfiguration>

  • Hyperion Brio: Computed Item Extract Number From String

    I would like to extract a number from a string in a computer item.  For example if I had a string such as "The customer purchased $5.00 of footballs", I would like to remove only the 5.00 from the string.  I would have to use the java functions in the results.  Any suggestions on how to do this?

    you can do this in the Results section with a computed column using the native string functions.  to break it down i have split it up a bit.
    strval is you string "The customer purchased $5.00 of footballs"
    position of $ = 25
         Instr ( strval, '$', 1, 1 )
    the starting position of the amount would then be 26
         Instr ( strval, '$', 1, 1 ) + 1
    position of decimal after $ = 26
         Instr ( strval, '.', Instr ( strval, '$', 1, 1 ), 1 )
    using Substr function you need to pick the string, the start value and the number of characters.
    string
         = strval
    start position
         = Instr ( strval, '$', 1, 1 ) + 1
    number of characters - location of decimal minus the start position plus 3 to get the cents
         = Instr ( strval, '.', Instr ( strval, '$', 1, 1 ), 1 ) - Instr ( strval, '$', 1, 1 )  + 3
    put all together
    Substr( strval, Instr ( strval, '$', 1, 1 ) + 1,  Instr ( strval, '.', Instr ( strval, '$', 1, 1 ), 1 ) - Instr ( strval, '$', 1, 1 )  + 3 ) * 1
    the multiply by 1 converts the string to number

  • Regular Expression for Invalid Number

    Hi everyone,
    I am using oracle version as follows:
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for 32-bit Windows: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    I am using regular expression to replace invalid values from a table.
    I received oracle error stating "ORA-01722 invalid number"
    My query looks like this:
    SELECT DISTINCT
    MRC_KEY,
    PURPOSE_CD,
    RESIDENCE_DESC,
    to_number(regexp_replace(ICAP_GEN_MADAPTIVE,'[+. ]?0?0?(\d+)[-.]?','\1')) as ICAP_GEN_MADAPTIVE,
    From
    MRRC_INT
    I am not sure what are the invalid values in the table so I can write regexp accordingly.
    Any guidance is highly appreciated!
    Thanks in advance
    J

    Or use DML error logging:
    create table t1
      (col1 number);
    exec dbms_errlog.create_error_log ('t1','t1_errors')
    insert into t1
    with t as
      (select '1' col from dual union all
       select '1.1' col from dual union all
       select '.11' col from dual union all
       select '0.11' col from dual union all
       select '-1' col from dual union all
       select '1,1' col from dual union all
       select '11a' col from dual union all
       select '1d' col from dual union all
       select '1e6' col from dual union all
       select '1e6.1' col from dual union all
       select '1e' col from dual
    select col
    from t
    log errors into t1_errors
    reject limit 20
    col col1 for 999,999,999.99
    select * from t1;
               COL1
               1.00
               1.10
                .11
                .11
              -1.00
       1,000,000.00
    col col1 for a30
    select * from t1_errors;
    ORA_ERR_NUMBER$ ORA_ERR_MESG$                  ORA_ERR_ROWID$       OR ORA_ERR_TAG$         COL1
               1722 ORA-01722: invalid number                           I                       1,1
               1722 ORA-01722: invalid number                           I                       11a
               1722 ORA-01722: invalid number                           I                       1d
               1722 ORA-01722: invalid number                           I                       1e6.1
               1722 ORA-01722: invalid number                           I                       1e

  • Regular expression to remove SIDs from list

    Hey everyone so I have a script and in it I try to find the current user, as well as the last user. Currently I'm using a regular expression to throw the System account SIDs and other things like that out of the list. However this doesn't seem to be taking
    SQL SIDs out of my list ie. ReportServer$LOCAL with the SID S-1-5-80-4264962431-3932693095-1576469926-235475122-2208986020
    What's the best way to get only user SIDs?
    Here's what I have so far:
    $Win32User = Get-WmiObject -Class Win32_UserProfile -ComputerName $Computer
    $Win32User = $Win32User | Where-Object {($_.SID -notmatch "^S-1-5-\d[18|19|20]$")}
    $Win32User = $Win32User | Sort-Object -Property LastUseTime -Descending
    $LastUser = $Win32User | Select-Object -First 1
    When I can this it breaks since there is no actual user tied to this SID:
    $UserSID = New-Object System.Security.Principal.SecurityIdentifier($LastUser.SID)
    $User = $UserSID.Translate([System.Security.Principal.NTAccount])
    Thanks for any help!!

    Start cmd.exe as your domain user and run whoami /user to get your own SID. You will get something like this:
    USER INFORMATION
    User Name SID
    ========================= =============================================
    DEMOSYSTEM\CustomAccount1 S-1-5-21-3419697060-3810377854-678604692-1000
    The last part of the SID, in this case 1000, is called RID. When you create a new user or computer object in your domain, only the RID will be different from your own SID. The RID starts on 1000 and increments as you create new objects.
    If you are only interested in user accounts from the same domain as your user, you can use a regex like this, only based on your own SID:
    $_.SID -match '^S-1-5-21-3419697060-3810377854-678604692-[\d]{4,10}$'

  • How to get page number from the PDF using Javascript

    Hi,
    We are having list of Single page PDF. The pdf are named in the order,
    ISBN_Author_01.PDF  (with real page number as i)
    ISBN_Author_02.PDF  (with real page number as ii)
    ISBN_Author_03.PDF  (with real page number as iii)
    ISBN_Author_04.PDF  (with real page number as 1)
    ISBN_Author_05.PDF  (with real page number as 2)
    ISBN_Author_06.PDF  (with real page number as 3)
    ISBN_Author_nn.PDF  (with real page number as 500)
    Here each pdf has a page number and in sequential order.
    The task is to check whether all the pdfs are in sequential order (i.e i, ii, iii, 1, 2, 3). If any page is missing, the script should throw an error report.
    To do this task, I am writing a Javascript to get the real page number from the PDF.
    Can anybody help me how to get the page number from the PDF using Javascript.
    Thanks,
    Gopal

    The "real" page number within a PDF is the count of the physical page starting at 0, zero.
    pageNum numPages
    The number printed on each page is the page label.
    setPageLabels  getPageLabel
    You will have to open each PDF and your script would need to know the page label for that file. I would expect you would need to build a 2 dimensional  array of the file names and the page label for the page within that array.

Maybe you are looking for