Regex API

Is it possible to use java.util.regex in an older version of JAVA?
If so, where and how to download this package?
Thank you.
William

Hi. This forum is specifically for problems related
to the Java Accessibility API's. I suggest asking
this question on one of the more general forums
such as "Java Programming". Thanks.

Similar Messages

  • Parse XML file with regex

    Hi,
    Is that possible to parse a xml file using regular expressions....if s what is the API needed
    thanx in advance

    Is that possible to parse a xml file using regular
    expressions....if s what is the API neededI'm sure it can be done. Here's the regex API:
    http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/package-summary.html
    http://www.javaregex.com/tutorial.html
    But that's not where regex is for. Better have a look at this:
    http://java.sun.com/xml/

  • JAVA Regex Illegal Characters

    Hello - I am trying to find a list of all illegal characters which have to be escaped in JAVA Regex pattern matching but I cannot find a complete list.
    Also I understand that when doing the replaceall function that there is a special list of characters which can't be used for that as well, which also have to be escaped differently.
    If anyone has access to a full complete list as to when to escape and how I would greatly appreciated it!
    Thanks,
    Dan

    I also noticed this below link:
    http://java.sun.com/docs/books/tutorial/extra/regex/literals.html
    It said the following characters are meta-characters in regex API:
    ( [ { \ ^ $ | ) ? * + .
    But it also says the below:
    Note: In certain situations the special characters listed above will not be treated as metacharacters. You'll encounter this as you learn more about how regular expressions are constructed. You can, however, use this list to check whether or not a specific character will ever be considered a metacharacter. For example, the characters ! @ and # never carry a special meaning.
    Does anyone know if there would be any issues if I escaped when a character didn't need to be escaped?

  • Regex fails to match, so it reports closest match

    Hi Guru's,
    I am using the regex API to match 2 lines of a message. If the match fails the 2 lines are reported to the user so they can see what has failed. Unfortunately the lines I am comparing are very long. (1000+ chars) So the user needs an indication of exactly what has failed.
    I was wondering if it is possible to use get a regex's closest match. So if whilst parsing, the regex managed to match 250/1000 characters I could tell user to start looking around character 250 for differences in the message.
    I have had a good google and can't find out how to do this, I have also quickly looked at the ORO perl5 api documentation, but cant find any code that implements this.
    Any help would be appreciated. thanks.

    I don't know of a way to do this, you could look into ParsePosition, but I don't know if you'll get usefull output if it doesn't match (it's worth a try, 'though).
    Otherwise you'd probably need a "real" parser. They can usually give very accurate positions for the errors (usually off-by-one token/line).

  • Ciscoworks 3.2 api

    Hi - runnning LMS 3.2 we would like to provide access to redseal software app and users.  Not having done this before, what is the best methodology ? is there a specific document also ?         
    Thanks in advance -        

    Hi
    I guess that depends on what you are trying to achieve.  There are many different API's within LMS.
    Using CM as an example :
    Data Extraction Engine (DEE) is a utility that provides servlet access to User Tracking, Layer 2 topology, and discrepancy data. (Allows you to use Campus Manager discrepancy APIs to retrieve latest discrepancy data from Campus Manager server).
    The following are the schemas used for exporting the user tracking data in XML format:
    Schema for User Tracking Data
    User Tracking Schema for Switch Data
    User Tracking Schema for Phone Data
    User Tracking Schema for Subnet Data
    Schema for Topology Data
    Schema for Discrepancy Data
    Using Servlet to Export Data from Campus Manager
    RME 4.2:
    The Baseline template uses java.util.regex engine for regular expressions. For more information, see the regex API guide for Java 1.4.2 from Sun: http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html
    As well as configuration archive APIs among others.
    This is a quick and certainly incomplete look at just 2 modules.  You best bet would be to engage you account team.
    But not knowing your final objectives then the below links may prove helpful to you.
    Here is the link to Open Database Schema Support in CiscoWorks LAN Management Solution 3.2
    And you may be simply looking for SDK Developers Guide for CiscoWorks Common Services 3.2 Northbound API 1.1

  • Regex convert URL's to link if NOT wrapped in quotes

    Hi there,
    Regular expressions have always been very difficult for me to understand. I currently have a regular expression to search a long string and replace URL's with HTML code to convert to a link. So...
    http://java.sun.com would become:
    <a href="http://java.sun.com">http://java.sun.com</a>It works EXCELLENT, however, I allow users to enter in HTML code for images using the following...
    <img src="http://www.url.to.image.com/image.gif">But, my regex replaces the URL with the link code above. To fix this, I want to simply only replace URL's with the HTML a href code if the URL is NOT surrounded by quotes. As I said above, I'm not good with regular expressions. The one I'm currenlty using was found on a forum too. Does anyone know how to accomplish this? Thanks very much, I appreciate it!

    scoobasteve1982 wrote:
    Can you or anyone else suggest a good place to learn more about regex...something that starts with the VERY BASICS? Thanks again!~Sure.
    The website regular-expressions.info has a chapter about Java regex:
    [http://www.regular-expressions.info/java.html]
    But I recommend you to have a look at the other sections of that site too.
    And Sun has a tutorial about their own regex-api, of course:
    [http://java.sun.com/docs/books/tutorial/essential/regex/]
    May the dark regex force be with you!
    ; )

  • RegEx and Database

    My problem is actually to take the name fields (lastname, firstname, middlename) in the database (all in Uppercase) and correctly display them. For instance:
    O'IRISHNAME --> as O'Irishname and
    LONGHYPHENATED-NAME as Longhyphenated-Name and
    LASTNAME/PARTTWO as Lastname/Parttwo and lastly
    LNAME PARTTWO as Lname Parttwo.
    Using the java.util.regex API seems to be the way to go.
    1) How do I make the corrections IN the database rather than say in a file? as a function?
    2) The apostrophe and the dash seem to be easy enough but the space (&160; or  ) wont return in a query. No luck with the / either.
    Point me in the right direction, please

    908644 wrote:
    My problem is actually to take the name fields (lastname, firstname, middlename) in the database (all in Uppercase) and correctly display them. For instance:
    Using the java.util.regex API seems to be the way to go.
    1) How do I make the corrections IN the database rather than say in a file? as a function?Then you may better have asked that here:
    PL/SQL
    Sing oracle has a regular expression implementation for SQL.
    2) The apostrophe and the dash seem to be easy enough but the space (&160; or  ) wont return in a query. No luck with the / either.Do it the other way around an look for "no letter" caracters: <tt>"([^[:alpha:]]*)([:alpha:])([:alpha:]*)"</tt>
    bye
    TPD

  • How to extract  different date format in text file

    well, iam new for using regex api(regular expression), In my project i want to extract the different format of date from the text file... date format will be 3rd june 2004, 03-06-2004, june 3rd and so on....
    can any body give me regular expression to extract the date from the text file...
    i will be very grateful..
    kareem

    date format will be 3rd june 2004, 03-06-2004, june 3rd and so on....The only way to do this (without implementing a "mind reader") is to determine in advance all the possible date formats that are possible in your input, and try to interpret each date using each of those formats until one of them passes.
    It's easy enough to handle june 3rd vs 3 june vs 3rd june, but 6/3 vs 3/6, of course, is ambiguous.

  • Compiling Java Applets

    Hi!
    I've had some trouble running Java Applets on my server. After some debugging I have found that it maters how and/or where they are compiled.
    I have taken a simple HelloWorldApplet and compiled on my server. Then when I try to access it from a client computer all I get is a grey box with no error message.
    I then found an applet at the Java home page where it was possible to download the .CLASS file. When I copied this file to my server it works just fine.
    So my question is: Should not a simple applet work, just because it's compiled with the latest Java Edition??
    The thing is though, when I check the box under Tools > Internet Options > Advanced, Use Java 2 v1.4.1 for <applet> every applet work just fine. But shoulden't a simple Java Applet run without this option?
    I run a MS IIS5 server and use MS IE as a browser.
    Please help me.
    /Fredrik

    Should not a simple applet work, just because it's compiled with the latest Java Edition??Don't need to compile/recompile using the latest JDK since each version is fully compatible with old versions but for advanced ones must to use "target" parameter. As example, if one applet is using regular expression API, formerly Regex API, must to compile this way:
    javac -target 1.4 yourSource.java .
    For simple applets as mentioned in your post, formerly AWT applets, don't need special care, they will work fine in any JVM, any browser any platform since this is the most primitive JVM (1.1) but in some OS the vendor supressed JVM..M$, so you must to use Java plug-in. It just supplies a Java virtual machine to run your applets/applications and in this sense becames the "native" VM. This is the better choice at all that warrants the best performance among VM's.
    At this moment you can be sure your OS was deployed without Java support of course and there aren't server constraints (applets run in client side) so maintain Sun's JVM as default and there will be no presentation faults. Moreover M$ JVM has a dangerous security bug and also is obsolete version.
    Regards.

  • Parsing text file with SGML tags

    <EMAIL>
    <ADDRESS>>[email protected]
    <DESC>>Email your questions to Click Here to E-mail
    <POP>
    <ADDRESS>N/A
    <ZIP>N/A
    How do you parse above text file which has SGML tags ? thanks

    Oh, sorry, if it's not an XML-file, then you properbly should use another approach. Where does the file come from? Could you properbly make it be a xml file ? ;-)
    Possible approaches are:
    * StringTokenizer, possibly with returning delimiters option enabled
    * good old make-it yourself indexOf/substring-method, ok... complicated
    * if you would like to handle the contents exactly like xml you could add a <?xml version="1.0"?><root> in the beginning and a </root> in the end and still use an xml parser, but keep character encodings in mind here.
    * another quite simple way that properbly fits best is java.util.regex API. if you want to use it, I can give you the code. it's easy.
    regards
    sven

  • Shorthand lab problems...

    ok were doing a shorthand lab in class using only the basic string and character commands and in the lab the user inputs a string like "This is FOR YOU TO try AND convert." and the output takes out all the vowels, and it replaces the word "for" with "4", and with "&", and two with "2".....now i had absolutely no trouble taking out the vowels, it's replacing the words thats the problem, my line of code takes out "and" and replaces it with "&" but it can only do it to the first and in the sentence so if the user put in "I went and shot a duck and dog" it would only change the first and "I went & shot a duck and dog" I need it to change both...here is the code
    if (n>-1)
         while (chr<n)
         char ch = str.charAt(temp+1);
         temp += 1;
         str0=str0+ch;
         chr = chr+1;     
         len = str.length();
         System.out.println(len);
         str0=str0+"&";
         chr = n+3;
         temp = n+3;
         while (chr<len)
            char ch = str.charAt(temp);
            temp += 1;
            str0 = str0+ch;
            chr = chr +1;
    }

    anything i can do about the whole hand become h& thing? so it only accepts it?Look at the regex api, and find the regex pattern to identify a word boundary
    http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.htmlI could give it to you, but you would be better off looking it up, and while you're there,
    having a glance at the other patterns, just for future reference.
    when you work it out - you have to cover before and after

  • Management of memory space - using totalMemory() and maxMemory()

    I'm writing an app and applet which if "users" select too many images to display would easily create an java.lang.OutOfMemoryError. When loading images, I can used totalMemory() and maxMemory() to see what's being used and available before and/or after loading an image.
    Is there a desirable "headroom" between totalMemory() and maxMemory() for "normal" JVM operations? In the case of the applet, there should be few net new objects created once the applet starts besides the images cached based on their selections.
    My thinking is to limit the total memory available for image caching based on the the difference maxMemory() - "headrooom" - "application base object totalMemory()"
    TIA,
    Roy

    RoyEpperson wrote:
    I understand profiling the application to see what demands it has. Assuming the app/applet logic is not creating and disposing new objects, how much space does the JVM need to do it's "housekeeping"? or is that already allocated on initial invocation of the application?It isn't as simple as that.
    I have gotten the VM (1.5 I believe) to start with something like a 3meg (somewhere around there) max heap. Although interesting that isn't usable.
    When the VM loads something, like the regex api it is hard to say what actually gets loaded when. And when you create instances it takes more space as well.
    So if you just want to guess then I would start with 32meg.

  • Simple Java regex question

    I have a file with set of Name:Value pairs
    e.g
    Action1:fail
    Action2:pass
    Action3:fred
    Using regex package I Want to get value of Name "Action1"
    I have tried diff things but I cannot figure out how I can do it. I can find Action1: is present or not but dont know how I can get value associated with it.
    I have tried:
    Pattern pattern = Pattern.compile("Action1");
    CharSequence charSequence = CharSequenceFromFile(fileName); // method retuning charsq from a file
    Matcher matcher = pattern.matcher(charSequence);
    if(matcher.find()){
         int start = matcher.end(0);
         System.out.println("matcher.group(0)"+ matcher.group(0));
    how I can get value associated with specific tag?
    thanks
    anmol

    read the data from the text file on a line basis and you can do:
    String line //get this somehow
    String[] keyPair = line.split(":")g
    System.out.println(keyPair[0]); //your name
    System.out.println(keyPair[1]); //your valueor if you've got the text file in one big string:
    String pattern = "(\\a*):(\\a*)$"; //{alpha}:{alpha}newline //?
    //then
    //do some things with match objects
    //look in the API at java.util.regex

  • Regex with xml for italicize or node creation

    Okay
    Guess it's a complex situation to explain.
    I am working on the text content of xml documents again. made quite a lot of progress with some of my other regex requirements.
    I am looking for a specific set of words to italicize say for example 'In Vitro'
    String Regex = "In Vitro";
    // here I get the text of a particular xml Node which is a text node
    String paragraph = nl.item(i).getNodeValue();
    //Value of paragraph before replace is "and lipids and In Vitro poorlysoluble(in water"
    String replace = "<Italic>In Vitro<Italic/>";
    String paragRepl = m.replaceFirst(replace);
    //Value of pargRepl after regex replace is "and lipids,?;:!and <Italic>In Vitro<Italic/> poorlysoluble(in water"
    //then I update the content of the node again
    nl.item(i)..setNodeValue(paragRepl);
    // save the xml documentthe italic tag is interpreted by our custom stylesheet to display "In Vitro" in italics, the reason it cannot do that is because the the character entities of the < and > have been put in the text content of the node i.e &lt; and &gt;. On closer examination of the text of the node after the document was saves, it appeared this way " &lt;Italic>In Vitro&lt;Italic/> ". For some reasom the greater than sign came out okay, but still no point, It didn't actually create a new node. I am not sure how you can automatically put tags around specific text you find in xml documents using regex, or If I have to create a new node at that point.
    it's xml so these entities come into picture.
    any help is greatly appreciated, in short I need to just add a set of tags to a particular regex I find in an xml document,
    thanks in advance
    Jeevan

    okay i am getting closer to the solution as there is an api call from another proprietary language that would do this
    but as I loop through the xml document, it keep selecting the text "In Vitro" even after it has been italicized.
    So I guess my next challenge is getting a regex which looks for "In Vitro" but not italicized
    For regex so far I have seen case insensitive handling, I have seen for italics
    basically if I I can get my hands on a regex for example
    String regex = "In Vitro && Not Italic"
    any help is appreciated
    Jeevan

  • How to determine mime type of multi-part message uploaded to rest api?

    I have a rest api that is used to upload data from different types of clients and serves as a proxy to write data to Azure blob storage. For testing, I'm using Fiddler on a PC.
    The code in my rest api that writes to blob storage looks like this:
    try
    await blockBlob.UploadFromStreamAsync(requestMessage.Content.ReadAsStreamAsync().Result);
    catch (Exception ex)
    HttpResponseMessage _hrm = new HttpResponseMessage(HttpStatusCode.InternalServerError);
    _hrm.ReasonPhrase = ex.Message;
    throw new HttpResponseException(_hrm);
    1 - How can I access the form-data that is included in the POST that has the original file name and the content-tyipe?
    2 - How can this info be passed to the blob when I write it out?  Currently, it is written out as a type of application/octet-stream instead of video/mp4.

    I think I found a solution using some other threads.  I'm not sure if it's the most performant or best but I'm able to get to the content-disposition and the content-type of the stream to get the details:
    Dictionary<string, string> lstLines = new Dictionary<string, string>();
    string[] _tmp;
    TextReader textReader = new StreamReader(requestMessage.Content.ReadAsStreamAsync().Result);
    string sLine = textReader.ReadLine();
    Regex regex = new Regex("(^content-type)|(^content-disposition)", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline);
    while (sLine != ""
    && sLine != null)
    if (regex.Match(sLine).Success)
    _tmp = sLine.Split(':');
    lstLines.Add(_tmp[0], _tmp[1]);
    sLine = textReader.ReadLine();

Maybe you are looking for