Regex exec() limit or interesting work

Hello,
It says that exec is better and has has not the 9 limit:
https://forums.netiq.com/showthread....ctor-questions
I LiveDebug my new supa-dupa-cool firewall collector and I bumped into
the //.exec() limit, which is RegExp.$9. The RegExp.$10 is nothing.
But if I use variable=//.exec(); variable[10] than it is good. What is
the difference? I know it works and not works , but you know what I
mean. Is it a built-in something?
The RegExp.$9 value is the same as variables[9] value. variable[14] is
still good.
http://tinyurl.com/kalbhlk says that it is unlimited and I have to use
it variable=//.exec() instead what the Collector Developer tutorial
says.
Thank you for your answers!
woodspeed
woodspeed's Profile: https://forums.netiq.com/member.php?userid=7232
View this thread: https://forums.netiq.com/showthread.php?t=52416

On 12/15/2014 06:24 AM, woodspeed wrote:
>
> It says that exec is better and has has not the 9 limit:
> https://forums.netiq.com/showthread....ctor-questions
> I LiveDebug my new supa-dupa-cool firewall collector and I bumped into
> the //.exec() limit, which is RegExp.$9. The RegExp.$10 is nothing.
> But if I use variable=//.exec(); variable[10] than it is good. What is
> the difference? I know it works and not works , but you know what I
> mean. Is it a built-in something?
The biggest differences that I have found are:
1. .exec() returns an array with no limits in size; as a result, it is
probably always the best way to return captured groups.
2. .test() gives you a nice boolean (match or not) and then you happen to
be able to get captured groups from the global RegExp object, but only up
through $9 as you noticed.
There may be performance benefits going one way or another, but I've done
a very small, statistically-insignificant, amount of testing and not
noticed much difference when the match works. When matches fail and the
regexes are not anchored (meaning the regex engine tries really hard to
find a match, at the cost of performance) they both quickly perform
terribly; I do not remember if one was worse than the other.
Summary: Use .exec(), set to a variable, and then test for null if you wan
to know if it succeeded/failed.
Good luck.
If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below...

Similar Messages

  • The Runtime.exec methods doesn't work well on Solaris ???

    I have two threads and I set the different running time.
    I use Runtime.exec to a run the command and use Process to get the process.
    It works properly in the windows2000 platform.
    However, when I transfer the platform to Solaris...and run the program...
    Two threads always at the same time....It is very wired....I always debug
    for 2 days....
    (at first I run "vmstat 1 2" command, later I change to "ls","rmdir"....etc,
    all of them don't work.....
    If I close the Runtime.exec..........Everything works well......)
    And I study the API. I found this message...
    The Runtime.exec methods may not work well for special processes on certain
    native platforms, such as native windowing processes, daemon processes,
    Win16/DOS processes on Win32, or shell scripts. The created subprocess does
    not have its own terminal or console.
    Could someone share her/his experience.....:(
    And if any other way I can run command inside java code instead of
    Runtime.exec.....???
    Please reply my mail to [email protected] I do appreciate your kindly &
    great help!!!!!!!!
    This is my code.......
    import java.io.*;
    import java.lang.*;
    import java.util.*;
    * <p>ServerThread1</p>
    * <p>??�X???��?�D???�X???, "Vmstat 1 2".</p>
    class ServerThread1 extends Thread{
    private ServerAgent Sa;
    public ServerThread1 (String Name, ServerAgent Sa){
    super(Name);
    this.Sa = Sa; file://Assign ServerAgent reference Sa
    public void run(){
    while(true){
    try{
    Thread.sleep(5000);
    catch (Exception e){
    System.out.println("ServerThread1 fails");
    System.out.println("Thread1 is running.");
    try {
    Runtime rt1 = Runtime.getRuntime();
    Process proc1 = rt1.exec("mkdir"); ------>If I close
    rt1.exec , two threads works seperately...........:(
    catch (Exception e) {
    System.out.println("Thread1 Error");
    class ServerThread2 extends Thread{
    private ServerAgent Sa;
    public ServerThread2 (String Name, ServerAgent Sa){
    super(Name);
    this.Sa = Sa;
    public void run(){
    while(true){
    try{
    Thread.sleep(15000);
    catch (Exception e){
    System.out.println("ServerThread2 fails");
    System.out.println("Thread2 is running.");
    try {
    Runtime rt2 = Runtime.getRuntime();
    Process proc2 = rt2.exec("vmstat 1 2"); ----->If I don't run
    the rt2.exe, two threads work seperately....
    catch (Exception e) {
    System.out.println("Thread2 Error");
    public class ServerAgent{
    private Vector v1 = new Vector();
    private Vector v2 = new Vector();
    private Hashtable currentData = new Hashtable();
    private static String startUpSwap = null;
    private static String startUpMem = null;
    public static void main(String[] arg) {
    ServerAgent s = new ServerAgent();
    ServerThread1 st1 = new ServerThread1("Thread1",s);
    ServerThread2 st2 = new ServerThread2("Thread2",s);
    st1.start();
    st2.start();

    If I close the Runtime.exec..........Everything works
    well......)You don't empty the output of the command, that blocks the process.
    A citation from
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
    Why Runtime.exec() hangs
    The JDK's Javadoc documentation provides the answer to this question:
    Because some native platforms only provide limited buffer size for standard input and output streams, failure to promptly write the input stream or read the output stream of the subprocess may cause the subprocess to block, and even deadlock.
    Try out something like this:
    String s;
    try {
       Process myProcess =
       Runtime.getRuntime().exec("ls -l"));
       DataInputStream in = new DataInputStream(
              new BufferedInputStream(myProcess.getInputStream()));
        while ((s = in.readLine()) != null) {
            out.println(s);
    catch (IOException e) {
        out.println("Error: " + e);
    }Another source of trouble under Unix is not having the correct permission for that user that executes the Java VM, which will be the permissions for the spawned subprocess. But this probably not the case, as you see something after exit.
    Regards,
    Marc

  • Say Credit limit block in working on certain documents

    HI FRIENDS
    I HAVE AN ERROR
    Say Credit limit block in working on certain documents

    Hi You have to look to the open-invoices / orderes/ ,.. if the total value is not hihger that you credit limit
    FD10N - Display balances
    FD11 - Analysis
    Paul

  • Time limit is not working correctly

    I'm using a dot-connection task in which my participants have to complete a picture by 'drawing' a line with the mouse to connect numbered dots. They get a time limit of 10 seconds to do this; and they have to do it with three different pictures, so the script is repeated two times with different pictures.
    However, very often the program stops drawing the line after about 5 seconds. So, the picture is visible for the full 10 seconds and the little clock showing the remaining time also counts down these 10 seconds, but the mouse just doesn't leave a line anymore after a couple of seconds.
    This does not happen every time, sometimes it does work for the whole ten seconds. Sometimes, it even works for the first picture, but not for the other two, for example, although the script should be completely the same, since it is just repeated.
    It seems to me that it is completely random at which try it works and at which it doesn't; does anyone know what is going on?
    Thank you!!

    You have enough syncpoint() and syncwait(0.01) statements in your script?
    Johann Fouché
    eLearning Solutions Architect
    Description: jfmm logo
    +27 82 853 1010
    <http://www.jfmultimedia.co.za/> http://www.jfmultimedia.co.za
    Skype:  johann.fouche

  • Why is getRuntime.exec() in jsp not working?

    Hello, could someone help me on the following problem?
    I have a jsp program which runs on tomcat server. In the jsp code, I am supposed to execute something. So I wrote the following codes:
    <%
    Runtime a = Runtime.getRuntime();
    java.lang.Process P = a.exec("javac Sieve.java");
    if(P.waitFor()!= 0)
    String s="Error while compiling";
    else
    String s="Commang get excecuted succesfully";
    %>
    It gives me the "Command exceduted successfully", but I couldn't find the Sieve.class file in the current directory. Also, if I change Sieve.java to S.java which doesn't exist, it gives me "error whild compliling". So I assume the command is executed. But where is the class file it produces? Can anyone help me?

    If you click on warnerj's profile, you'll see that he's piled up a pretty impressive number of Dukes. He's helped a lot of people, and the Dukes account is proof of that.
    IMO, it's not a matter of warnerj having too high an opinion of himself. He's simply telling posters that their chances of getting his (proven) assistance are diminished by cross-posting, because he considers it rude.
    Anyone posting a question here depends on the good will of volunteers for answers. warnerj is giving them a lesson in manners that will maximize their chances of getting a solid answer from someone like him. It's in the OP's self-interest to not cross-post.
    You're right - there are a lot of people who read these forums who can offer "advice". Lots of them are also chuckleheads. All advice isn't equal. I see a lot of answers that are misleading at best and just plain wrong at worst. I also see some names that I've started to associate with solid advice. Why alienate the good advisers needlessly by cross-posting?
    Sun's rules and the etiquette of behavior acceptable by the community here are two different things. warnerj is providing the OP a lesson in the behavior acceptable to this community. Nothing wrong with that. It's more good education, in my view. - MOD

  • HDD Formats - Other than 2GB limit, should FAT32 work OK with FCE4?

    I know about the 2GB filesize limit, but are there any other limitations when using FAT32 format for my external drive with FCE4?
    Have been using this setup for more than six months, but I've got a really weird problem going on with some AVCHD clips I have ingested where the filenames keep changing. Spontaneously. While browsing the directory in Finder!
    In FCE, it's resulting in media disconnection issues when I re-open sequences. Completely messes up QT reference files too.
    I've seen various references to 'should use HFS+' when using external drives with FCE - but nothing definitive? Could someone set me straight? Have I been misguided in thinking that FAT32 would be okay?
    I use the same HDD from time to time with a WinXP computer -- so keeping it as FAT32 is my preferred option. The HDD in question is a LaCie Porsche 160GB on firewire 400.
    Thanks in advance
    Shane

    FCE does not officially support working with FAT32 drives. The drive should be formatted as Mac OS Extended if you are using it with FCE.
    The fact that you are getting weird behavior such as spontaneous file name changes indicates that something is amiss. Are you sure you haven't used any non-printing ASCII characters, or ? / \ " | > * in the filenames - that would definitely cause problems.
    While I understand your desire to use the drive with both your Mac and your PC, for use with FCE you really should reformat to Mac OS Extended. There is an app called MacDrive that you can put on your PC to read Mac formatted drives.

  • Runtime.exec()  in Java not working in Oracle 10 Application Server

    Hi ,
    I am trying to call a .exe file which is in the Web Application folder .
    I am Using Process p = Runtime.exec("path to .exe file ")
    This code is working fine when used with JBOSS , but not working with Oracle Application server .
    Please tell me whether i need to do any chnages to make it work
    Thanks in advance .

    I ran a quick test with your code, I just had to make some small changes, and things work for me...
    I'm testing with JDeveloper 10g 10.1.3.2.0 ...
    The only thing I wonder is DBUser DBPass DBHost, those are not the actual values, correct?, neither they are environment variables?...
    In the server hosting your OAS, you should try running the whole CMD line from the start/run dialog ... make sure it works in that server ...
    Here is the code used in my test:
    In JSP:
      <%@ page import="runexepkg.*" %>
      <% 
      String msg = "";
      try
      RunEXE p = new RunEXE();
      msg = p.main1();
      catch(Throwable t)
         System.out.println("Exception Raised");
         t.printStackTrace();
      %>
      <%= msg %>In Java Class:
    package runexepkg;
    import java.sql.*;
    public class RunEXE
        String ss="";
        public String main1()
        try
            Runtime rt=Runtime.getRuntime();
            Process p = rt.exec("CMD /C start C:\\oraappserver\\j2ee\\WebGis\\applications\\PowerGis\\web\\WEB-INF\\classes\\GisProject\\cust_data_1.exe DBUser DBPass DBHost");
            System.out.println("Command has been executed");
            Class.forName("oracle.jdbc.driver.OracleDriver");
            Connection con = DriverManager.getConnection("jdbc:oracle:thin:@DBHost:DBPort:orcl","DBUser","DBPass");
            System.out.println("Test Connection ========== "+con);
            Statement st = con.createStatement();
            ResultSet rs = st.executeQuery("SELECT SYSDATE FROM DUAL");
            if(rs.next())
                ss="Command has been executed - Database has been accessed";
            else
                ss="Command has been executed - Database was not accessed";
        catch(Throwable t)
            System.out.println("Exception raised, command has NOT been executed");
            ss="Exception raised, command has NOT been executed";
            t.printStackTrace();
        return ss;
    }Edited by: Rodolfo Ferrari on Jul 23, 2009 10:40 PM

  • Note size limit and slight work-around in Lyrics

    I tried to reply to a older post, but since it's archived I wasn't able to so I'll simply reference it.
    I followed the suggestions from the following post in order to fit more continuous viewable text on my iPod:
    http://discussions.apple.com/thread.jspa?messageID=3412651#3412651
    According to the post, since you can fit appx. 256 MB into ID3 tags (and only 4K in Notes), that you could create a short song only for the purpose of storing text in the Lyrics tab. I followed the suggestions and while I was able to fit a little more than twice as much text in the Lyric as I could the note, only a portion of the lyrics was actually viewable on the iPod.
    Let me clarify. I could fit the ENTIRE text that I wanted (a text file 200K) into the Lyrics tab and could view all of it in iTunes, only a small portion was viewable on the iPod itself.
    So, I was able to slightly work-around the note size limit, I wasn't able to expand it by as much as was suggested in the original post/thread.
    Does anyone have any ideas? Obviously, I can't get back to the original posters personally (Chris CA, b noir, and chanyiwai), so hopefully some of them will see this thread.
    Has anyone else found a better work-around?

    The ID3 tag can be 256MB but how that tag is implemented by Apple in iTunes, I don't know.
    Haven't heard of any other workarounds for more text.
    Really though, the iPod is not designed for documents/texts.

  • Runtime.exec(" find . -name *.txt -exec rm {} \; ") don't work why?

    Hi,
    I have to exec a unix command like " find . -name *.txt -exec rm {} \; " in a java program, but it don't work fine because of option -exec.
    The source is :
    String line="",lineErr="",comando="";
    try
    comando=" find . -name *.txt -exec rm {} \; ";
    process = IstanzaRuntime.exec(comando);
    inStream = process.getInputStream();
    errStream = process.getErrorStream();
    There are problems only in commands with options like -exec that permit to exec 2 commands in one .
    There is another way to write the command?
    Thanks in advance
    Lorenzo

    1. you have to use quotes around *.txt
    i.e \"*.txt\"
    or '*.txt'
    depending how you are calling the command.
    2. the directory should be specified otherwise you will be deletinfg files from the USER HOME directory.
    find . = find /USERHOME
    find ./mydir = find /USERHOME/mydir
    find /usr/tmp/mytmpdir = find /usr/tmp/mytmpdir (i.e root stem).
    3. the {} should not be a problem.

  • Deviation from Commitment Limit doesn't work for one Business Partner

    Hi Experts,
    I'm hoping you can help me with an issue I have at the moment.
    I have an authorisation set to trigger for Delivery Notes which deviate by £1 over the Commitment Limit. 
    This authorisation works fine for all Business Partners apart from one. 
    All Business Partners have an account balance, and all Business Partners have their commitment limit set as £1.  The only difference with the Business Partner with the Authorisation that won't trigger is that they pay by Credit Card...
    Can anyone help me with this please?
    Many thanks,
    Caroline

    Hi Gordon,
    Thanks so much for the reply.
    Yes... but I can't find anything.  I managed to replicate the scenario again by making Incoming Payments with Cheque Payment Means which a future date, and the making a deposit for these Cheques with a future date.  I was wondering if this could maybe have something to do with it... perhaps if the credit cards are future dated maybe.  I found Note 1227330 - do you know if this might have something to do with this scenario too?
    Many thanks,
    Caroline

  • QoS bandwidth rate limit don't work

    Hello
    Buy a router RV120W, and one of the reasons is limit of bandwidth (QoS). I set up a profile of 1-256 kbps limit, and apply it to the only VLAN that is configured, but does not work and can navigate using the full bandwidth of the internet connection. My firmware version is 1.0.2.6
    Screenshots attached
    thanks
    screenshots attached

    Struggling with a similar issue:
    the setup: internet adsl <--1mbs--> combined router/modem <--100mbs--> RV 120W
    Internet speed is 1mbs. I want to priotize voip calls (via port) and deprioritize one machine (doing downloads). rest of the network should have something in between.
    Firmware upgraded to 1.0.3.10
    I created the profiles bindings, then in QoS settings, selected Priority, Wan total bandwidth 1mbs, and distributed my profiles onto low/med/high (10/31/61).
    When what should be low is downloading, it gets the whole 1mbs and the other are dead slow.
    Changed to rate limit, changed the parameters, etc... no more luck.
    Can you please shed some light as how to configure this - in my case, the whole bw of wan is being used, and prioriization is not happening,
    Rgds

  • If i run program via Runtime.getRuntime().exec, UrlConnection doesn't work.

    I have two pograms.
    One GUI which allow us directly runs server application and display output.
    Two server application which operates with http.
    Under Windows XP operation system everything works fine. If i run server application via comand like " java -jar **** " , everything works fine. But if i run server application via GUI under Win2000, server application doesn't work. Application freeze if try to get output stream from Url connection.
    Can you help me please?
    url = new URL("http://neco");
    connection = (HttpURLConnection)url.openConnection();
    connection.setRequestMethod("POST");
    connection.setDoInput(true);
    connection.setDoOutput(true);
    connection.setAllowUserInteraction(true);
    connection.setReadTimeout(10);
    connection.setUseCaches(false);
    // Right There !!!
    output = new DataOutputStream(connection.getOutputStream());

    It is probably because the getOutputStream() or getErrorStream() of Process is blocked waiting for you to read from those streams.
    See http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.htmlIn short read from getOutputStream() from its own thread and also read from getErrorStream in another thread. If you are using 1.5 you can use ProcessBuilder and combine the OutputStream and ErrorStream into one stream and then you just need one thread. For you information, in 1.5 Runtime.exec() just call through to ProcessBuilder.

  • Interesting work..need suggestions

    hello super-users
    I m in front a interesting task and I need some of your experience and suggestions....
    Im creating a multi-language dvd with lots of tracks and menu. the point is to reduce at the max the work of the editors..at the moment we are creating a menu and etc...for every language..sucking away space and time....
    The idea to use a script to start up the dvd with a menu that let the user to choose the language and to navigate to the dvd in the language selected...
    Now....is it possible to do so without create all the different menus....using the add languagge and creating a "storage" of menus for each menu...or the way we are working is fine...
    any ideas or suggestion is more than welcome...at the moment im knocking my head on the wall....
    thanks

    I guess there are many ways of doing this, but heres what I did.
    If I were you, I would leave the attempt of trying to use the language flag. This depends on the users having their DVD-player initially set for the correct language. You cannot override the setting which reads the language, and then picks the correct version of the menu, so you are better off creating all the menus. It's fairly quick tho. Create all the menus for one language. Make sure your satisfied, and then duplicate them.
    In my case, the only difference in language was the audio(7 streams), so I made an initial menu with 7 buttons, one for each language. Each of these buttons, when activated, runs a script.
    The script (7 different) sets system stream(audio) 1-7 and moves the value 1-7 to GPRM0. The value in GPRM0 is now a placeholder for future scripts. It then jumps to the selected languages main menu. All tracks have the same numbering of the audio streams so when a track is being played, the initially selected audio will play. The main menu has four sub menus, and every sub menu has x buttons playing a different track. To be able to return to the correct languages sub menu after playing a track, I created one script representing the end jump for each sub menu. The script moved the value of the button last pressed (SPRM8) into GPRM 1, then divided that value by 1024 (to be able to return to last button pressed). Then there are 7 entries which each has a return to a languages sub menu if the value in GPRM 0 is a match. Each entry also has a GPRM based button jump which uses GPRM 1. In order to link the different tracks end jumps to the correct script, I had to keep track of which sub menu that originally played the track. So if I'm on menu "Norwegian-sub2", and I have 10 tracks playing from that menu, all the 10 tracks will have the "Sub2-End" script as end jump.
    Im sure this could have been explained (and done) better, but I hope it gets you a step or two further in your project.

  • Runtime.exec with spaces not working EVEN using String[]!!

    Hi everyone,
    I need to start the rmi registry from some code,and i need to pass it the classpath of two jars when initialising it. My problem is that the paths I set aren't taken when they contain a space.
    Here's the code:
    <code>
    String rmiRegistryCommandLine[] = new String[] {
    + System.getProperty("java.home")
    + "\\bin\\rmiregistry.exe\"",
    "-J-Djava.class.path=\""+System.getProperty("user.dir")+"\\MyJar.jar\"",
    "1099"};
                                            Runtime.getRuntime().exec(rmiRegistryCommandLine);
    </code>
    I know that Runtime.exec(String) tokenizes the input, which is why I'm not using it, but Runtime.exec(String[]) isn't supposed to tokenize the input. System.getProperty("user.dir") can contain a space, so I put quotes around that, but I need the -J-Djava.class.path in the same string. I tried breaking it up into two more separate strings but it didn't even run for normal non-space paths then. I am sure that if the whole -J-Dblah....upto MyJar.jar was in quotes then it would work, but I need the classpath in quotes separately as it could contain a space.
    Can anyone help me get this working?

    Ya, that's fine but the command line I want to pass is:
    d:\j2sdk1.4.0\bin\rmiregistry.exe -J-Djava.class.path=d:\my dir with spaces\MyJar.jar;d:\my more dir with spaces\MyJar2.jar 1099
    If I say
    arg[0]="d:\\j2sdk1.4.0\\bin\rmiregistry.exe";, that's finebut arg[1] is the problem
    if I say
    arg[1]="-J-Djava.class.path=d:\\my dir with spaces\MyJar.jar; d:\\my more dir with spaces\\MyJar2.jar";, then it definitely won't work on 9X machines and probably not on NT.
    if I break up arg[1] into:
    arg[1]="-J-Djava.class.path=";
    arg[2]="d:\\my dir with spaces\\MyJar.jar";
    arg[3]=";";
    arg[4]="d:\\my more dir with spaces\\MyJar2.jar";I'll need to put quotes around the two individual two class paths or else it won't work.
    I find though that if I put the classpath as follows
    d:\"my dir with spaces"\MyJar.jar then it seems to work.
    I think a regular expression function to search for any directory with spacees and then put quotes around it and reinsert it into the path would be the solution.

  • Exec fscommand doesn't work ?!

    Hi !
    By pressing a button in my flash project I have to launch
    another application. The .exe file is located in a different
    directory, called Vademekum, on the same CD. I somehow cannot find
    the right combination for this to happen. Can anybody help. I used
    the script below:
    on (release) {
    fscommand("exec", "Vademekum.exe");
    Instead of Vademekum.exe in the second quote I also used
    these combinations:
    Vademekum/Vademekum.exe
    ../Vademekum/Vademekum.exe
    ..\\Vademekum\\Vademekum.exe
    ..\Vademekum\Vademekum.exe
    What am I doing wrong. Thanks in advance. B

    fscommand functionality in CS3 has been a problem for quite
    some time, yet there isn't much on the forums about it. Here is a
    link to another thread that might be interesting:
    http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=15&catid=194&threadid =1264958&highlight_key=y&keyword1=fscommand
    I haven't tried the fix at the bottom, but it explains what
    happens when CS3 Flash tries to execute fscommand.

Maybe you are looking for