aspose file tools*
The moose likes Java in General and the fly likes Replacing Content of Line using Code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Replacing Content of Line using Code" Watch "Replacing Content of Line using Code" New topic
Author

Replacing Content of Line using Code

ashesh sasidharan
Greenhorn

Joined: Dec 07, 2011
Posts: 7
Hi All,

Please help to solve this issue.



The above code takes the input as velow



The Formula is just used to test some condition based on result....In above case we use from V1 till V10.The Java code mentioned above is used to conver V1 as V1_0 to uniquely identify each variable by appending a unique number after variable ( like V1 becomes V1_0 and so on ).

The issue i am facing is when i try to convert V1 as V1_0 it is also searching for v10 and converting it as V1_00, similarly for V2 its converting V2 as V2_0 and V20 as V2_00.



This is the result after converting at present.
Please help to modify above code to differentiate between V1 and V10 and so on.

Regards
Ashesh

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39383
    
  28
This question is too difficult for “beginning”, so I shall move it.

You have posted a block of unintelligible text with incomprehensible variable names (V1 V2) and no spaces around operators. Also, the line is too long to read.
I cannot understand the question. What are you trying to do? Are you trying to parse that line? Are you trying to insert “_0” after each number? Are you telling the program to look for V followed by a digit, when it should be V followed by one or more digits?
You might do that by matching a regular expression, possibly for "V\\d+". You might do well to insert backwards. Start with the last occurrence of V\\d+ and work towards the first occurrence. That way the indices you are inserting at will not change. If you find V123 at index 345, you will want to insert at index 349, i.e. index + length of match. That will change any indices after 349, but will not change indices before that.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Replacing Content of Line using Code