Regex refactoring

Hi all,
I'm currently in the process of refactoring some code to which i need to make bulk changes. I have a particular example in mind. I've got a lot of constants defined, for example's sake similar to-
public static final Car CAR_333 = new Car("CAR_333", BodyType.SEDAN, "RED", 2, null, null, false);There's a lot of these constants in this class. But we've changed the way we're representing BodyType- it's no longer going to be an object but a String representation (essentially so we don't have to serialise the object when we sent it across, but that's another kettle of fish). So the new code will need to look like the following:
public static final Car CAR_333 = new Car("CAR_333", "SEDAN", "RED", 2, null, null, false);My question is, what would be the best way to make this change? I've done a lot of these bulk changes through regular expressions, but I can't quite seem to fathom one to turn BodyType.XXX into "XXX".
Any thoughts?

uncle_alice wrote:
The exact syntax will vary depending on the tool you use to do the replacements. In my editor (EditPad Pro), I would use search: BodyType\.(\w+)
replace: "$1" In a Java program I would do something like str = str.replaceAll("BodyType\\.(\\w+)", "\"$1\"");
Brilliant!
Many thanks Uncle_Alice, you've saved me from a lot of tedium!

Similar Messages

  • Entity bean (ejb 3.0) refactoring problem

    I didn't find a better method than regenerating an entity bean after modifying the table definition and renaming the class after deleting the old one.
    I'm not sure i can delete the old class representing the entity bean before regenerating it without any effects into the others entity beans.
    It work fine but still a little problem. The refactoring process didn't change the name of the entity bean into the select clauses into queynamed injection.

    I am facing a similar problem. Does JDeveloper 10g (10.1.3.3.0) provide an automatic process to update an Entity Bean definition when the underlying database table definition changes?
    I also noticed that for JDeveloper to create all the relationships (i.e. @OneToMany, @ManyToOne) between multiple Entity beans, I need to create all the Entity beans together in one pass using the wizard. If two entities depend on each other, and not created together, JDeveloper will not create the relationships between them. Is there a way around that?
    Thank you

  • Can I refactor this query to use an index more efficiently?

    I have a members table with fields such as id, last name, first name, address, join date, etc.
    I have a unique index defined on (last_name, join_date, id).
    This query will use the index for a range scan, no sort required since the index will be in order for that range ('Smith'):
    SELECT members.*
            FROM members
            WHERE last_name = 'Smith'
            ORDER BY joindate, idIs there any way I can get something like the following to use the index (with no sort) as well:
    SELECT members.*
            FROM members
            WHERE last_name like 'S%'
            ORDER BY joindate, idI understand the difficulty is probably; even if it does a range scan on every last name 'S%' (assuming it can?), they're not necessarily in order. Case in point:
    Last_Name:  JoinDate:
    Smith          2/5/2010
    Smuckers     1/10/2010An index range scan of 'S%' would return them in the above order, which is not ordered by joindate.
    So is there any way I can refactor this (query or index) such that the index can be range scanned (using LIKE 'x%') and return rows in the correct order without performing a sort? Or is that simply not possible?

    xaeryan wrote:
    I have a members table with fields such as id, last name, first name, address, join date, etc.
    I have a unique index defined on (last_name, join_date, id).
    This query will use the index for a range scan, no sort required since the index will be in order for that range ('Smith'):
    SELECT members.*
    FROM members
    WHERE last_name = 'Smith'
    ORDER BY joindate, idIs there any way I can get something like the following to use the index (with no sort) as well:
    SELECT members.*
    FROM members
    WHERE last_name like 'S%'
    ORDER BY joindate, idI understand the difficulty is probably; even if it does a range scan on every last name 'S%' (assuming it can?), they're not necessarily in order. Case in point:
    Last_Name:  JoinDate:
    Smith          2/5/2010
    Smuckers     1/10/2010An index range scan of 'S%' would return them in the above order, which is not ordered by joindate.
    So is there any way I can refactor this (query or index) such that the index can be range scanned (using LIKE 'x%') and return rows in the correct order without performing a sort? Or is that simply not possible?Come on. Index column order does matter. "LIKE 'x%'" actually is full table scan. The db engine accesses contiguous index entries and then uses the ROWID values in the index to retrieve the table rows.

  • Problems with String.split(regex)

    Hi! I'm reading from a text file. I do it like this: i read lines in a loop, then I split each line into words, and in a for loop I process ale words. Heres the code:
    BufferedReader reader = new BufferedReader(new FileReader(file));
    String line;
    while ((line = reader.readLine()) != null) {
        String[] tokens = line.split(delimiters);
        for (String key : tokens) {
    doSthToToken();
    reader.close();The problem is that if it reads an empty line, such as where is only an "\n", the tokens table has the length == 1, and it processes a string == "". I think the problem is that my regex delimiters is wrong:
    String delimiters = "\\p{Space}|\\p{Punct}";
    Could anybody tell me what to do?

    Ok, so what do you suggest?I suggest you don't worry about it.
    Or if you are worried then you need to test the two different solutions and do some timings yourself.
    And how do you know the regex lib is so slow and badly written?First of all slowness is all relative. If something takes 1 millisecond vs 4 milliseconds is the user going to notice? Of course not which is why you are wasting your time trying to optimize an equals() method.
    A general rule is that any code that is written to be extremely flexible will also be slower than any code that is written for a specific function. Regex are used for complex pattern matching. StringTokenizer was written specifically to split a string based on given delimiters. I must admit I haven't tested both in your exact scenario, but I have tested it in other simple scenarios which is where I got my number.
    By the way I was able to write my own "SimpleTokenizer" which was about 30% faster than the StringTokenizer because I was able to make some assumptions. For example I only allowed a single delimiter to be specified vs multiple delimiter handled by the StringTokenizer. Therefore my code could be very specific and efficient. Now think about the code for a complex Regex and how general it must be.

  • Can we eliminate " from a String using regEx?

    Hi,
    I have a process and we are calling an external web service.
    Within code, I am setting the response from web service(string) to bpm object and using the same object in jsp for presentation.
    For Ex.
    bpmObject.empName = response from web service.
    within the jsp, have a java script where in I am validating the value.
    var empNm= "<f:fieldValue att="bpmObject.empName" onlyValue="true"/>";
    It works fine but some times when response from web service is having '"' - double quote, it is giving error.
    For Ex. bpmObject.empName = FirstName "SecondName" then the javascript error occurs. how can we remove the double quote from this?
    Tried bpmObject.empName.replace(from : "\"", @to : " ") but it is still giving the same output FirstName "SecondName"
    It works fine when I test by using a String str = "FirstName\"SecondName\"".replace(from : "\"", @to : " ") is giving correct result i.e. FirstName SecondName
    Can RegEx help in this?
    Thanks

    I know its better to handle in jsp/javascript
    var empNm= "<f:fieldValue att="bpmObject.empName" onlyValue="true"/>";
    but the above line is giving javascript error always.
    how to handle the same in bpm fpr code?
    Edited by: Sreekant on Mar 3, 2011 1:44 AM

  • Regex find and replace

    I have inherited a boatload of code that I need to "tweak".
    Currently, it contains many hundreds of refrences to a 2d
    array and
    references constants that I want to change to function calls.
    i.e.
    v(Svc,FutWTMargin)
    I want that to be changed into:
    v(Svc,getcol("FutWTMargin"))
    Now the bit in quotes "FutWTMargin" has many variations, but
    the structure
    of the original 2d array references are all consistent - it's
    just that
    there are several hundred of them that I need to change.
    Can someone help out with a regex that can change the
    FutWTMargin part to
    getcol("FutWTMargin") regardless of what the FutWTMargin text
    might actually
    say?
    Note to self... must learn regex at some point!
    Cheers,
    Rob
    http://robgt.com/ [Tutorials and
    Extensions]
    Firebox stuff:
    http://robgt.com/firebox
    Skype stuff:
    http://robgt.com/skype
    Dell stuff:
    http://robgt.com/dell
    SatNav stuff:
    http://robgt.com/satnav

    Thanks Mick!
    Cheers,
    Rob
    http://robgt.com/ [Tutorials and
    Extensions]
    Firebox stuff:
    http://robgt.com/firebox
    Skype stuff:
    http://robgt.com/skype
    Dell stuff:
    http://robgt.com/dell
    SatNav stuff:
    http://robgt.com/satnav

  • Find Replace from Textfile with regex

    Hello.
    I'm wondering if anyone knows about an existing script that does a find/replace by list like the script "FindChangeByList.jsx" that comes with every InDesign installation.
    This consists of tow parts, the script itself with the functionality and a simple textfile where you have simple one-liners capable of find/replace with regex.
    the Textfile:
    //FindChangeList.txt
    //A support file for the InDesign CS4 JavaScript FindChangeByList.jsx
    //This data file is tab-delimited, with carriage returns separating records.
    //The format of each record in the file is:
    //findType<tab>findProperties<tab>changeProperties<tab>findChangeOptions<tab>description
    //Where:
    //<tab> is a tab character
    //findType is "text", "grep", or "glyph" (this sets the type of find/change operation to use).
    //findProperties is a properties record (as text) of the find preferences.
    //changeProperties is a properties record (as text) of the change preferences.
    //findChangeOptions is a properties record (as text) of the find/change options.
    //description is a description of the find/change operation
    //Very simple example:
    //text          {findWhat:"--"}          {changeTo:"^_"}          {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}          Find all double dashes and replace with an em dash.
    //More complex example:
    //text          {findWhat:"^9^9.^9^9"}          {appliedCharacterStyle:"price"}          {include footnotes:true, include master pages:true, include hidden layers:true, whole word:false}          Find $10.00 to $99.99 and apply the character style "price".
    //All InDesign search metacharacters are allowed in the "findWhat" and "changeTo" properties for findTextPreferences and changeTextPreferences.
    //If you enter backslashes in the findWhat property of the findGrepPreferences object, they must be "escaped"
    //as shown in the example below:
    //{findWhat:"\\s+"}
    grep          {findWhat:"  +"}          {changeTo:" "}          {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}          Find all double spaces and replace with single spaces.
    grep          {findWhat:"\r "}          {changeTo:"\r"}          {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}          Find all returns followed by a space And replace with single returns.
    grep          {findWhat:" \r"}          {changeTo:"\r"}          {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}          Find all returns followed by a space and replace with single returns.
    grep          {findWhat:"\t\t+"}          {changeTo:"\t"}          {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}          Find all double tab characters and replace with single tab characters.
    grep          {findWhat:"\r\t"}          {changeTo:"\r"}          {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}          Find all returns followed by a tab character and replace with single returns.
    grep          {findWhat:"\t\r"}          {changeTo:"\r"}          {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}          Find all returns followed by a tab character and replace with single returns.
    grep          {findWhat:"\r\r+"}          {changeTo:"\r"}          {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}          Find all double returns and replace with single returns.
    text          {findWhat:" - "}          {changeTo:"^="}          {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}          Find all space-dash-space and replace with an en dash.
    text          {findWhat:"--"}          {changeTo:"^_"}          {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}          Find all dash-dash and replace with an em dash.
    The script:
    //FindChangeByList.jsx
    //An InDesign CS5.5 JavaScript
    @@@BUILDINFO@@@ "FindChangeByList.jsx" 3.0.0 15 December 2009
    //Loads a series of tab-delimited strings from a text file, then performs a series
    //of find/change operations based on the strings read from the file.
    //The data file is tab-delimited, with carriage returns separating records.
    //The format of each record in the file is:
    //findType<tab>findProperties<tab>changeProperties<tab>findChangeOptions<tab>description
    //Where:
    //<tab> is a tab character
    //findType is "text", "grep", or "glyph" (this sets the type of find/change operation to use).
    //findProperties is a properties record (as text) of the find preferences.
    //changeProperties is a properties record (as text) of the change preferences.
    //findChangeOptions is a properties record (as text) of the find/change options.
    //description is a description of the find/change operation
    //Very simple example:
    //text          {findWhat:"--"}          {changeTo:"^_"}          {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}          Find all double dashes and replace with an em dash.
    //More complex example:
    //text          {findWhat:"^9^9.^9^9"}          {appliedCharacterStyle:"price"}          {include footnotes:true, include master pages:true, include hidden layers:true, whole word:false}          Find $10.00 to $99.99 and apply the character style "price".
    //All InDesign search metacharacters are allowed in the "findWhat" and "changeTo" properties for findTextPreferences and changeTextPreferences.
    //If you enter backslashes in the findWhat property of the findGrepPreferences object, they must be "escaped"
    //as shown in the example below:
    //{findWhat:"\\s+"}
    //For more on InDesign scripting, go to http://www.adobe.com/products/indesign/scripting/index.html
    //or visit the InDesign Scripting User to User forum at http://www.adobeforums.com
    main();
    function main(){
              var myObject;
              //Make certain that user interaction (display of dialogs, etc.) is turned on.
              app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
              if(app.documents.length > 0){
                        if(app.selection.length > 0){
                                  switch(app.selection[0].constructor.name){
                                            case "InsertionPoint":
                                            case "Character":
                                            case "Word":
                                            case "TextStyleRange":
                                            case "Line":
                                            case "Paragraph":
                                            case "TextColumn":
                                            case "Text":
                                            case "Cell":
                                            case "Column":
                                            case "Row":
                                            case "Table":
                                                      myDisplayDialog();
                                                      break;
                                            default:
                                                      //Something was selected, but it wasn't a text object, so search the document.
                                                      myFindChangeByList(app.documents.item(0));
                        else{
                                  //Nothing was selected, so simply search the document.
                                  myFindChangeByList(app.documents.item(0));
              else{
                        alert("No documents are open. Please open a document and try again.");
    function myDisplayDialog(){
              var myObject;
              var myDialog = app.dialogs.add({name:"FindChangeByList"});
              with(myDialog.dialogColumns.add()){
                        with(dialogRows.add()){
                                  with(dialogColumns.add()){
                                            staticTexts.add({staticLabel:"Search Range:"});
                                  var myRangeButtons = radiobuttonGroups.add();
                                  with(myRangeButtons){
                                            radiobuttonControls.add({staticLabel:"Document", checkedState:true});
                                            radiobuttonControls.add({staticLabel:"Selected Story"});
                                            if(app.selection[0].contents != ""){
                                                      radiobuttonControls.add({staticLabel:"Selection", checkedState:true});
              var myResult = myDialog.show();
              if(myResult == true){
                        switch(myRangeButtons.selectedButton){
                                  case 0:
                                            myObject = app.documents.item(0);
                                            break;
                                  case 1:
                                            myObject = app.selection[0].parentStory;
                                            break;
                                  case 2:
                                            myObject = app.selection[0];
                                            break;
                        myDialog.destroy();
                        myFindChangeByList(myObject);
              else{
                        myDialog.destroy();
    function myFindChangeByList(myObject){
              var myScriptFileName, myFindChangeFile, myFindChangeFileName, myScriptFile, myResult;
              var myFindChangeArray, myFindPreferences, myChangePreferences, myFindLimit, myStory;
              var myStartCharacter, myEndCharacter;
              var myFindChangeFile = myFindFile("/FindChangeSupport/FindChangeList.txt")
              if(myFindChangeFile != null){
                        myFindChangeFile = File(myFindChangeFile);
                        var myResult = myFindChangeFile.open("r", undefined, undefined);
                        if(myResult == true){
                                  //Loop through the find/change operations.
                                  do{
                                            myLine = myFindChangeFile.readln();
                                            //Ignore comment lines and blank lines.
                                            if((myLine.substring(0,4)=="text")||(myLine.substring(0,4)=="grep")|| (myLine.substring(0,5)=="glyph")){
                                                      myFindChangeArray = myLine.split("\t");
                                                      //The first field in the line is the findType string.
                                                      myFindType = myFindChangeArray[0];
                                                      //The second field in the line is the FindPreferences string.
                                                      myFindPreferences = myFindChangeArray[1];
                                                      //The second field in the line is the ChangePreferences string.
                                                      myChangePreferences = myFindChangeArray[2];
                                                      //The fourth field is the range--used only by text find/change.
                                                      myFindChangeOptions = myFindChangeArray[3];
                                                      switch(myFindType){
                                                                case "text":
                                                                          myFindText(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions);
                                                                          break;
                                                                case "grep":
                                                                          myFindGrep(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions);
                                                                          break;
                                                                case "glyph":
                                                                          myFindGlyph(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions);
                                                                          break;
                                  } while(myFindChangeFile.eof == false);
                                  myFindChangeFile.close();
    function myFindText(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions){
              //Reset the find/change preferences before each search.
              app.changeTextPreferences = NothingEnum.nothing;
              app.findTextPreferences = NothingEnum.nothing;
              var myString = "app.findTextPreferences.properties = "+ myFindPreferences + ";";
              myString += "app.changeTextPreferences.properties = " + myChangePreferences + ";";
              myString += "app.findChangeTextOptions.properties = " + myFindChangeOptions + ";";
              app.doScript(myString, ScriptLanguage.javascript);
              myFoundItems = myObject.changeText();
              //Reset the find/change preferences after each search.
              app.changeTextPreferences = NothingEnum.nothing;
              app.findTextPreferences = NothingEnum.nothing;
    function myFindGrep(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions){
              //Reset the find/change grep preferences before each search.
              app.changeGrepPreferences = NothingEnum.nothing;
              app.findGrepPreferences = NothingEnum.nothing;
              var myString = "app.findGrepPreferences.properties = "+ myFindPreferences + ";";
              myString += "app.changeGrepPreferences.properties = " + myChangePreferences + ";";
              myString += "app.findChangeGrepOptions.properties = " + myFindChangeOptions + ";";
              app.doScript(myString, ScriptLanguage.javascript);
              var myFoundItems = myObject.changeGrep();
              //Reset the find/change grep preferences after each search.
              app.changeGrepPreferences = NothingEnum.nothing;
              app.findGrepPreferences = NothingEnum.nothing;
    function myFindGlyph(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions){
              //Reset the find/change glyph preferences before each search.
              app.changeGlyphPreferences = NothingEnum.nothing;
              app.findGlyphPreferences = NothingEnum.nothing;
              var myString = "app.findGlyphPreferences.properties = "+ myFindPreferences + ";";
              myString += "app.changeGlyphPreferences.properties = " + myChangePreferences + ";";
              myString += "app.findChangeGlyphOptions.properties = " + myFindChangeOptions + ";";
              app.doScript(myString, ScriptLanguage.javascript);
              var myFoundItems = myObject.changeGlyph();
              //Reset the find/change glyph preferences after each search.
              app.changeGlyphPreferences = NothingEnum.nothing;
              app.findGlyphPreferences = NothingEnum.nothing;
    function myFindFile(myFilePath){
              var myScriptFile = myGetScriptPath();
              var myScriptFile = File(myScriptFile);
              var myScriptFolder = myScriptFile.path;
              myFilePath = myScriptFolder + myFilePath;
              if(File(myFilePath).exists == false){
                        //Display a dialog.
                        myFilePath = File.openDialog("Choose the file containing your find/change list");
              return myFilePath;
    function myGetScriptPath(){
              try{
                        myFile = app.activeScript;
              catch(myError){
                        myFile = myError.fileName;
              return myFile;
    This is a very useful and easy to maintain script which even people who cant write scripts (but know how to use regex) can do complex search replace mass replacements.
    Would love to find something like this for FrameMaker 12 (as i can't write scripts myself).
    regards
    daniel

    I have visited that site. The first item in the external link says: "You can also configure Firefox to automatically search for text when you type any characters outside of a text field. When typing in a text field these characters should show up in the text field and not trigger the Quick Find bar. "
    What I am looking for is the exact opposite. Once my first search is entered in the text box, and the info comes back, I want to start typing the next symbol, and have it automatically show up in the text box, not the Quick Find box. That is how it was working up until a couple of months ago.

  • Flash Builder 4.7 refactoring is broken

    I'm unable to rename methods or classes in Flash Builder 4.7. Attempting to refactor gives this error:
    "An unexpected exception occurred while performing the refactoring. See the error log for more details."
    This happens in all my projects. I've recreated my workspace from scratch and the error persists.
    I recently overlaid the AIR 3.6 SDK in Flash Builder. I tried reverting to AIR 3.5, which I'd backed up, but that did not fix the problem either.
    The error in the log follows:
    java.lang.reflect.InvocationTargetException
              at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:421)
              at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.run(RefactoringWizardDia log2.java:331)
              at org.eclipse.ltk.ui.refactoring.RefactoringWizard.internalPerformFinish(RefactoringWizard. java:605)
              at org.eclipse.ltk.ui.refactoring.UserInputWizardPage.performFinish(UserInputWizardPage.java :153)
              at org.eclipse.ltk.ui.refactoring.RefactoringWizard.performFinish(RefactoringWizard.java:678 )
              at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.okPressed(RefactoringWiz ardDialog2.java:455)
              at org.eclipse.jface.dialogs.Dialog.buttonPressed(Dialog.java:472)
              at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:624)
              at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:240)
              at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
              at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4128)
              at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1457)
              at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1480)
              at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1465)
              at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1270)
              at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3974)
              at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3613)
              at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
              at org.eclipse.jface.window.Window.open(Window.java:801)
              at com.adobe.flexbuilder.editors.derived.refactoring.FlexOpenRefactoringWizardOperation$1.ru n(FlexOpenRefactoringWizardOperation.java:144)
              at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
              at com.adobe.flexbuilder.editors.derived.refactoring.FlexOpenRefactoringWizardOperation.run( FlexOpenRefactoringWizardOperation.java:157)
              at com.adobe.flexbuilder.as.editor.ui.actions.refactoring.SimpleRenameRefactorAction.run(Sim pleRenameRefactorAction.java:78)
              at com.adobe.flexbuilder.as.editor.ui.actions.refactoring.RenameRefactorAction.run(RenameRef actorAction.java:89)
              at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
              at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:185)
              at org.eclipse.ui.internal.handlers.LegacyHandlerWrapper.execute(LegacyHandlerWrapper.java:1 09)
              at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
              at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.jav a:508)
              at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
              at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:468)
              at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:786)
              at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:885 )
              at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboar d.java:567)
              at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:508)
              at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboar d.java:123)
              at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
              at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1069)
              at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4127)
              at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1457)
              at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1480)
              at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1465)
              at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1494)
              at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1490)
              at org.eclipse.swt.widgets.Canvas.sendKeyEvent(Canvas.java:463)
              at org.eclipse.swt.widgets.Composite.keyDown(Composite.java:594)
              at org.eclipse.swt.widgets.Display.windowProc(Display.java:5473)
              at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
              at org.eclipse.swt.widgets.Widget.callSuper(Widget.java:220)
              at org.eclipse.swt.widgets.Widget.windowSendEvent(Widget.java:2092)
              at org.eclipse.swt.widgets.Shell.windowSendEvent(Shell.java:2252)
              at org.eclipse.swt.widgets.Display.windowProc(Display.java:5535)
              at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
              at org.eclipse.swt.widgets.Display.applicationSendEvent(Display.java:4989)
              at org.eclipse.swt.widgets.Display.applicationProc(Display.java:5138)
              at org.eclipse.swt.internal.cocoa.OS.objc_msgSend(Native Method)
              at org.eclipse.swt.internal.cocoa.NSApplication.sendEvent(NSApplication.java:128)
              at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3610)
              at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696)
              at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660)
              at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
              at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
              at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
              at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
              at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
              at com.adobe.flexbuilder.standalone.FlashBuilderApplication.start(FlashBuilderApplication.ja va:79)
              at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
              at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLau ncher.java:110)
              at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.jav a:79)
              at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
              at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
              at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
              at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
    Caused by: java.lang.NullPointerException
              at org.eclipse.core.runtime.Path.isPrefixOf(Path.java:632)
              at org.eclipse.core.internal.localstore.FileSystemResourceManager.resourceForLocation(FileSy stemResourceManager.java:286)
              at org.eclipse.core.internal.localstore.FileSystemResourceManager.containerForLocation(FileS ystemResourceManager.java:266)
              at org.eclipse.core.internal.resources.WorkspaceRoot.getContainerForLocation(WorkspaceRoot.j ava:120)
              at com.adobe.flexbuilder.codemodel.internal.as.indices.SearchIndexGateway.loadProject(Search IndexGateway.java:414)
              at com.adobe.flexbuilder.codemodel.internal.as.indices.SearchIndexGateway.loadProject(Search IndexGateway.java:422)
              at com.adobe.flexbuilder.codemodel.internal.as.indices.SearchIndexGateway.createQuery(Search IndexGateway.java:376)
              at com.adobe.flexbuilder.codemodel.internal.as.indices.SearchIndexGateway.getOccurrences(Sea rchIndexGateway.java:188)
              at com.adobe.flexbuilder.codemodel.internal.as.indices.SearchIndexGateway.access$4(SearchInd exGateway.java:172)
              at com.adobe.flexbuilder.codemodel.internal.as.indices.SearchIndexGateway$SearchIndex.getOcc urrences(SearchIndexGateway.java:556)
              at com.adobe.flexide.refactoring.core.ASRenameProcessor.checkFinalConditions(ASRenameProcess or.java:199)
              at com.adobe.flexide.refactoring.core.VariableRenameProcessor.checkFinalConditions(VariableR enameProcessor.java:139)
              at org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring.checkFinalConditi ons(ProcessorBasedRefactoring.java:224)
              at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.ja va:85)
              at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:121 )
              at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:2 09)
              at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
              at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAda pter.java:87)
              at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)

    I'm experiencing the same issue with FB 4.7 x64 - a fresh install with AIR updated to 3.7.   Anyone from Adobe able to comment on this?  Will there be a patch released to fix it?
    Stack trace:
    java.lang.reflect.InvocationTargetException
        at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:421)
        at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.run(RefactoringWizardDia log2.java:331)
        at org.eclipse.ltk.ui.refactoring.RefactoringWizard.createChange(RefactoringWizard.java:631)
        at org.eclipse.ltk.ui.refactoring.RefactoringWizard.computeUserInputSuccessorPage(Refactorin gWizard.java:470)
        at org.eclipse.ltk.ui.refactoring.UserInputWizardPage.computeSuccessorPage(UserInputWizardPa ge.java:74)
        at org.eclipse.ltk.ui.refactoring.UserInputWizardPage.getNextPage(UserInputWizardPage.java:1 14)
        at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.nextOrPreviewPressed(Ref actoringWizardDialog2.java:497)
        at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.access$2(RefactoringWiza rdDialog2.java:494)
        at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2$1.widgetSelected(Refacto ringWizardDialog2.java:693)
        at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:240)
        at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
        at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
        at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
        at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
        at org.eclipse.jface.window.Window.open(Window.java:801)
        at com.adobe.flexbuilder.editors.derived.refactoring.FlexOpenRefactoringWizardOperation$1.ru n(FlexOpenRefactoringWizardOperation.java:144)
        at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
        at com.adobe.flexbuilder.editors.derived.refactoring.FlexOpenRefactoringWizardOperation.run( FlexOpenRefactoringWizardOperation.java:157)
        at com.adobe.flexbuilder.as.editor.ui.navigator.FlexPackageExplorerRenameAction.run(FlexPack ageExplorerRenameAction.java:141)
        at org.eclipse.ui.actions.BaseSelectionListenerAction.runWithEvent(BaseSelectionListenerActi on.java:168)
        at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionI tem.java:584)
        at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
        at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java :411)
        at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
        at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
        at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
        at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696)
        at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660)
        at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
        at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
        at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
        at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
        at com.adobe.flexbuilder.standalone.FlashBuilderApplication.start(FlashBuilderApplication.ja va:79)
        at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLau ncher.java:110)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.jav a:79)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
        at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
    Caused by: java.lang.NullPointerException
        at org.eclipse.core.runtime.Path.isPrefixOf(Path.java:636)
        at org.eclipse.core.internal.localstore.FileSystemResourceManager.resourceForLocation(FileSy stemResourceManager.java:286)
        at org.eclipse.core.internal.localstore.FileSystemResourceManager.containerForLocation(FileS ystemResourceManager.java:266)
        at org.eclipse.core.internal.resources.WorkspaceRoot.getContainerForLocation(WorkspaceRoot.j ava:120)
        at com.adobe.flexbuilder.codemodel.internal.as.indices.SearchIndexGateway.loadProject(Search IndexGateway.java:414)
        at com.adobe.flexbuilder.codemodel.internal.as.indices.SearchIndexGateway.loadProject(Search IndexGateway.java:422)
        at com.adobe.flexbuilder.codemodel.internal.as.indices.SearchIndexGateway.loadProject(Search IndexGateway.java:422)
        at com.adobe.flexbuilder.codemodel.internal.as.indices.SearchIndexGateway.createQuery(Search IndexGateway.java:376)
        at com.adobe.flexbuilder.codemodel.internal.as.indices.SearchIndexGateway.getOccurrences(Sea rchIndexGateway.java:188)
        at com.adobe.flexbuilder.codemodel.internal.as.indices.SearchIndexGateway.access$4(SearchInd exGateway.java:172)
        at com.adobe.flexbuilder.codemodel.internal.as.indices.SearchIndexGateway$SearchIndex.getOcc urrences(SearchIndexGateway.java:556)
        at com.adobe.flexide.refactoring.core.ASRenameProcessor.checkFinalConditions(ASRenameProcess or.java:199)
        at com.adobe.flexide.refactoring.core.TypeRenameProcessor.checkFinalConditions(TypeRenamePro cessor.java:199)
        at org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring.checkFinalConditi ons(ProcessorBasedRefactoring.java:224)
        at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.ja va:85)
        at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:121 )
        at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
        at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAda pter.java:87)
        at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
    Root exception:
    java.lang.NullPointerException
        at org.eclipse.core.runtime.Path.isPrefixOf(Path.java:636)
        at org.eclipse.core.internal.localstore.FileSystemResourceManager.resourceForLocation(FileSy stemResourceManager.java:286)
        at org.eclipse.core.internal.localstore.FileSystemResourceManager.containerForLocation(FileS ystemResourceManager.java:266)
        at org.eclipse.core.internal.resources.WorkspaceRoot.getContainerForLocation(WorkspaceRoot.j ava:120)
        at com.adobe.flexbuilder.codemodel.internal.as.indices.SearchIndexGateway.loadProject(Search IndexGateway.java:414)
        at com.adobe.flexbuilder.codemodel.internal.as.indices.SearchIndexGateway.loadProject(Search IndexGateway.java:422)
        at com.adobe.flexbuilder.codemodel.internal.as.indices.SearchIndexGateway.loadProject(Search IndexGateway.java:422)
        at com.adobe.flexbuilder.codemodel.internal.as.indices.SearchIndexGateway.createQuery(Search IndexGateway.java:376)
        at com.adobe.flexbuilder.codemodel.internal.as.indices.SearchIndexGateway.getOccurrences(Sea rchIndexGateway.java:188)
        at com.adobe.flexbuilder.codemodel.internal.as.indices.SearchIndexGateway.access$4(SearchInd exGateway.java:172)
        at com.adobe.flexbuilder.codemodel.internal.as.indices.SearchIndexGateway$SearchIndex.getOcc urrences(SearchIndexGateway.java:556)
        at com.adobe.flexide.refactoring.core.ASRenameProcessor.checkFinalConditions(ASRenameProcess or.java:199)
        at com.adobe.flexide.refactoring.core.TypeRenameProcessor.checkFinalConditions(TypeRenamePro cessor.java:199)
        at org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring.checkFinalConditi ons(ProcessorBasedRefactoring.java:224)
        at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.ja va:85)
        at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:121 )
        at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
        at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAda pter.java:87)
        at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)

  • How to check special characters in java code using Java.util.regex package

    String guid="first_Name;Last_Name";
    Pattern p5 = Pattern.compile("\\p{Punct}");
    Matcher m5 =p5.matcher(guid);
    boolean test=m5.matches();
    I want to find out the weather any speacial characters are there in the String guid using regex.
    but above code is always returning false. pls suggest.

    Pattern.compile ("[^\\w]");The above will match any non [a-zA-Z0-9_] character.
    Or you could do
    Pattern.compile("[^\\s^\\w]");This should match anything that is not a valid charcter and is not whitespace.

  • Reading a String Literally - Finding the "\" Character with a Regex

    How do I search for "\" characters in a string? Such as..
    String text = "Temp\temp.txt";
    The problem is that Java will read "\t" as a tab, so that
    System.out.println(text);
    Will return
    Temp emp.txt
    Also, searching for the regex "\\\\" will return a null result, presumably because Java interprets the "\t" as a tab character, not as a literal "\" followed by a literal "t".
    How do I get Java to read the string without interpreting it?
    Thanks in advance

    Try also this:
    public static void main(String[] args) {
              String test1 = "String with a\\t which is not a tab but a t preceeded with a \\ character";
              String test2 = "String with a \t which is a tab";
              System.out.println("This are the Strings as user sees / enters them:");
              System.out.println(test1);
              System.out.println(test2);
              System.out.println("");
              System.out.println("***********************************************************");
              System.out.println("");
              System.out
                        .println("Splitting first string using a \\\\\\\\ regex which will be interpreted by the regex engine as \\\\ which will represent a \'\\\' character:");
              System.out.println("");
              for (String s : test1.split("\\\\")) {
                   System.out.println(s);
              System.out.println("");
              System.out.println("***********************************************************");
              System.out.println("");
              System.out.println("Splitting the second string just the same way:");
              System.out.println("");
              for (String s : test2.split("\\\\")) {
                   System.out.println(s);
         }and read the console output.
    It should be:
    This are the Strings as user sees / enters them:
    String with a\t which is not a tab but a t preceeded with a \ character
    String with a       which is a tab
    Splitting first string using a \\\\ regex which will be interpreted by the regex engine as \\ which will represent a '\' character:
    String with a
    t which is not a tab but a t preceeded with a
    character
    Splitting the second string just the same way:
    String with a       which is a tab

  • How to replace regex match into a char value (in the middle of a string)

    Hi uncle_alice and other great regex gurus
    One of my friends has a peculiar problem and I cant give him a solution.
    Using String#replaceAll(), i.e. NOT a Matcher loop, how could we convert matched digit string such as "65" into a char of its numeric value. That is, "65" should be converted into letter 'A'.
    Here's the failing code:
    public class GetChar{
      public static void main(String[] args){
        String orig = "this is an LF<#10#> and this is an 'A'<#65#>";
        String regx = "(<#)(\\d+)#>";
        //expected result : "this is an LF\n and this is an 'A'A"
        String result = orig.replaceAll(regx, "\\u00$2");
        // String result = orig.replaceAll(regx, "\\\\u00$2"); //this also doesn't work
        System.out.println(result);

    I don't know that we have lost anything substantial.i think its just that the kind of task this is
    especially useful for is kind of a blind-spot in the
    range of things java is a good-fit for (?)
    for certain tasks (eg process output munging) an
    experienced perl programmer could knock up (in perl)
    using built-in language features a couple of lines
    which in java could takes pages to do. If the cost is
    readability/maintainability/expandability etc.. then
    this might be a problem, but for a number of
    day-to-day tasks it isn't
    i'm trying to learn perl at the moment for this exact
    reason :)Yes. And when a Java source-code processor(a.k.a. compiler) sees the code like:
    line = line.replaceAll(regexp,  new String(new char[] {(char)(Integer.parseInt("$1"))}));or,
    line = line.replaceAll(regexp,  doMyProcessOn("$1")); //doMyProcess returns a Stringa common sense should have told him that "$1" isn't a literal string "$1" in this regular expression context.
    By the way, I abhor Perl code becaus of its incomprehensibleness. They can't be read by an average common sense. Java code can be, sort of ...

  • Java.util.regex error

    Hello,
    I checked JavaDoc multiple times but do not see what is wrong with
    myString.replaceAll("D:\\web\\mars","")which results in
    java.util.regex.PatternSyntaxException: Illegal/unsupported escape squence near index 7
    D:\web\mars
           ^
         at java.util.regex.Pattern.error(Unknown Source)
         at java.util.regex.Pattern.escape(Unknown Source)
         at java.util.regex.Pattern.atom(Unknown Source)
         at java.util.regex.Pattern.sequence(Unknown Source)
         at java.util.regex.Pattern.expr(Unknown Source)
         at java.util.regex.Pattern.compile(Unknown Source)
         at java.util.regex.Pattern.<init>(Unknown Source)
         at java.util.regex.Pattern.compile(Unknown Source)
         at java.lang.String.replaceAll(Unknown Source)
         at ArticleImageImportProcessor.main(ArticleImageImportProcessor.java:40)
    Exception in thread "main" please, every suggestion/hint is most appeciated

    You have to "encode" backslash twice, first for String purpose and second time because of special meaning of '\' in regular expressions.
    It should looks like
    myString.replaceAll("D:\\\\web\\\\mars","")

  • 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: How to find out which part of the pattern failed?

    Hi there,
    I was wondering: is there any way to find out where the pattern matching failed?
    Say I got the string "John Paul Yoko Ringo", and I want to match it against the pattern /John Paul George Ringo/.
    I would like to know something like "pattern failed at index 11", or if I had groups something like "matching group 3 failed".
    Is there any way to do this? Thanks in advance!
    Best regards,
    - Torben

    jschell wrote:
    I would like to know something like "pattern failed at index 11", or if I had groups something like "matching group 3 failed".
    Is there any way to do this? Thanks in advance!
    I wonder if that is reasonable. It means that the parse tree for the regex would need to keep mapping information.
    At a minimum it is going to require an array, not a single result, because a regex can 'fail' in many ways.
    Consider the following regex with the following input
    /(a|b)d/
    abababababx
    Where does it 'fail'?Right. If you just want the character position at which it failed, those tools might tell you that as part of a bigger picture. But by itself, without any context, that number's not necessarily meaingful. A given character can be examined many times due to backtracking. Part of the expression could succeed for part of the input, then the expression might fail for the rest, so we backtrack, and may get several more failures, then more partial successes, all at different points, then ultimately it may fail anywhere within the input.
    So just knowing where isn't enough. You need to know what steps were taken to get there. I do think these tools provide that, though I haven't looked closely.

  • 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

Maybe you are looking for

  • PL/SQL Call Back function is never called

    Hi, I have a AQ set to run a PL/SQL Call Back procedure, but the procedure is never called. Oracle version is 11.2.0.2 Standard Edition When I query aq$<queue>, the MSG_STATE column is always "ready". This is the queue creation script begin   DBMS_AQ

  • Synch iphone to macbook pro

    ive had my iphone for about 10 months and ive been using a pc for everything, I just got a macbook pro and I was wondering how I could keep all my contacts and songs from my PC and transfer them to my macbook pro. I dont even know if this is possible

  • How do I invite contacts to an event in my  calendar?

    How do I invite contacts to an event in my  calendar?

  • Editing text in photoshop elements

    I would like to edit text in a band promo poster created in photoshop.  When I open the file in photoshop elements, all I see is the main photograph of our band, I can't find the text.  Any suggestions on where to look ?  All I want to do is change o

  • Dreamweaver wont boot after Snow Leopard upgrade

    Upgraded 5yr old MacBook Pro to Snow Leopard. Now Dream Weaver won't boot at all. Do I have to upgrade to a new version of Dream Weaver?