Results 1 to 4 of 4
- 12-07-2011, 06:03 AM #1
Member
- Join Date
- Dec 2011
- Posts
- 6
- Rep Power
- 0
URGENT HELP : Java Regular Expression
Hi All,
This is my first post with this forum.
I have a situation where am stuck with the Pattern matcher to compile my regular expression.
I have a formula to be parsed as below :
This is my code snippet:Java Code:APDM_ABS_LT_WL-A+WL_BL|APDM_ABS_LT_WL-A+WL_BL|-1.00E+20|1.00E+20|-1.00E+20|1.00E+20|-1.00E+20|1.00E+20|1.00E+20|abs(if((x1 = 1 || x1 = 2), y = 0, y=1))
Ok now the problem i am facing is that i am not able to get the required result with the currently used Pattern.compile.Java Code:private void genDisWithCalPara(File calParaFile) { ArrayList<String> calParaNameAL = new ArrayList<String>(500); ArrayList<String> calPara4LimitDisAL = new ArrayList<String>(500); ArrayList<String> calParaFormulaAL = new ArrayList<String>(500); try{ //If the constructor throws an exception, the finally block will NOT execute BufferedReader reader = new BufferedReader(new FileReader(calParaFile)); Pattern pattern = Pattern.compile("(.*)(\\|.*\\|.*\\|.*\\|.*\\|.*\\|.*\\|.*\\|.+\\|)(.*)"); Matcher matcher = null; try{ String aLine = null; while((aLine=reader.readLine()) != null){ System.out.println(aLine); matcher = pattern.matcher(aLine); if (matcher.find()){ System.out.println("g(1)="+matcher.group(1)); System.out.println("g(2)="+matcher.group(2)); System.out.println("g(3)="+matcher.group(3)); calParaNameAL.add(new String(matcher.group(1))); calPara4LimitDisAL.add(new String(matcher.group(2))); calParaFormulaAL.add(new String(matcher.group(3))); }//end if continue; }//end while }finally{ reader.close(); }//end finally } catch (Exception e){ JNotify.getInstance().log(JNotify.ERROR,"000" , "JCalPara.genDisWithCalPara" , "ConfigFileNotFound" , JNotify.getStackTraceString(e) ); System.exit(1); } //end catch try { if (calParaNameAL.size() > 0){ createDatawcalDIS(calParaNameAL,calParaFormulaAL); createLimitwcalDIS(calParaNameAL,calPara4LimitDisAL); } } catch (Exception e){ JNotify.getInstance().log(JNotify.WARN,"000" , "JCalPara.genDisWithCalPara" , "calParaNameAL is Empty" , JNotify.getStackTraceString(e) ); } System.exit(1); }
Whenever i have an OR (||) symbol in the forumula (if((x1 = 1 || x1 = 2), y = 0, y=1)),it shows me an different result as it read || symbol as pipe(|) and not as logical OR .
When i run above i get the following output:
Java Code:APDM_ABS_LT_WL-A+WL_BL|APDM_ABS_LT_WL-A+WL_BL|-1.00E+20|1.00E+20|-1.00E+20|1.00E+20|-1.00E+20|1.00E+20|1.00E+20|abs(if((x1 = 1 || x1 = 2), y = 0, y=1)) g(1)=APDM_ABS_LT_WL-A+WL_BL|APDM_ABS_LT_WL-A+WL_BL g(2)=|-1.00E+20|1.00E+20|-1.00E+20|1.00E+20|-1.00E+20|1.00E+20|1.00E+20|abs(if((x1 = 1 || g(3)= x1 = 2), y = 0, y=1))
Expected Result should be like :
Please help me to achieve the same...Java Code:APDM_ABS_LT_WL-A+WL_BL|APDM_ABS_LT_WL-A+WL_BL|-1.00E+20|1.00E+20|-1.00E+20|1.00E+20|-1.00E+20|1.00E+20|1.00E+20|abs(if((x1 = 1 || x1 = 2), y = 0, y=1)) g(1)=APDM_ABS_LT_WL-A+WL_BL g(2)=|APDM_ABS_LT_WL-A+WL_BL|-1.00E+20|1.00E+20|-1.00E+20|1.00E+20|-1.00E+20|1.00E+20|1.00E+20| g(3)=abs(if((x1 = 1 || x1 = 2), y = 0, y=1))
Regards
AsheshLast edited by asheshrocky; 12-07-2011 at 06:06 AM.
- 12-07-2011, 07:29 AM #2
Member
- Join Date
- Dec 2011
- Posts
- 6
- Rep Power
- 0
Re: URGENT HELP : Java Regular Expression
Any suggestions experts ?
- 12-07-2011, 02:15 PM #3
Re: URGENT HELP : Java Regular Expression
Yes
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 12-07-2011, 02:52 PM #4
Member
- Join Date
- Dec 2011
- Posts
- 6
- Rep Power
- 0
Similar Threads
-
Java regular expression optimization - help needed
By dpkcv in forum Advanced JavaReplies: 0Last Post: 09-30-2011, 08:42 AM -
Urgent Regular expression to allow only alpha characters and % wildcard
By MJoe in forum Advanced JavaReplies: 2Last Post: 06-17-2010, 12:44 PM -
Java Regular expression ?
By sidharth in forum Advanced JavaReplies: 12Last Post: 11-14-2009, 11:09 AM -
Java Regular Expression help
By royalibrahim in forum Advanced JavaReplies: 11Last Post: 11-12-2009, 01:27 AM -
java regular expression to search block/string/word exist in a paragraph?
By sidharth in forum Advanced JavaReplies: 2Last Post: 11-11-2009, 05:56 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks