joe nesbitt

Greenhorn
+ Follow
since Dec 05, 2009
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by joe nesbitt

Hi all,

i have a regex that checks if the content between the 5th and 6th occurence of | is "" as follows:

(TEST\\|[||]*\\|\\|[||]*\\|[||]*\\|)\"\"")

It works fine with string.replaceall(). But when same pattern is used with java.util.regex.Pattern and Matcher classes, Matcher.find() is always false. Does it mean that the above regex must not contain the match part, I tried that but in vain.

Could someone, show me as how to use the above regex in combination of Pattern and Match classes.

Thanks in advance.
11 years ago
Hi all,

The following regex works when used in string.replaceall() but not in case of string.replaceFirst().

String:



Expected output:




Regex:



Output (not desired):






No changes are made to the string, not sure why.

Please help!

Thanks in advance.
11 years ago
How to check if the content between 5th and 6th occurence of | has alphanumeric content and then check if the content between 2nd and 3rd | is empty, if so, make it STR.


My current regex is replacing all empty positions with STR. But I need it to change it only between 2nd and 3rd position.

Regex I am using:
(STR\\|[\\|\\|]*\\\\|)\\|\\|", "$1|STR|" );

The current (wrong output):

TEST|x|STR|y|z|Y""|cccc|bbb|STR|"

Any help is appreciated.
11 years ago
Any help please!

11 years ago
Hi all,

I am new to java 6 regex.

I have a string with the following content ( each line separated by \r\n).

Existing string:

aaaa|
TEST|x||y|z|""|cccc|bbb|"
xxxx|
TEST|x||y|z|Something|cccc|bbb|";
TEST|x|ST|y|z|""|cccc|bbb|";
TEST|x||y|z|""XYZ|cccc|bbb|";
TEST|x||y|z|Y""|cccc|bbb|";



The expected strign content:

aaaa|
TEST|x||y|z||cccc|bbb|
xxxx|
TEST|x|ST|y|z|Something|cccc|bbb|
TEST|x|ST|y|z|""|cccc|bbb|
TEST|x|ST|y|z|""XYZ|cccc|bbb|
TEST|x|ST|y|z|Y""|cccc|bbb|


Basically, if the content between 2nd and 3rd occurance of | is blank and if the content betweeen 5th and 6th occurance of | is "", then make it blank.(Ex: Line 2 in the EXISTING STRING)
Also if the content between 5th and 6th occurrence is not empty and not "" then if the content between 2nd and 3rd occurance of | is blank make it ST.(eX: Line 4,6,7 in existing string)
In other scenarios, nothing needs to be changed.
How to make it possible with Regex replaceall or Pattern/match.

I tried few things but in vain. - str.replaceAll( "(TEST\\\\|[\\|\\|]*\\\\|\\\\|[\\|\\|]*\\\\|[\\|\\|]*\\\\|)\"\"\\|", "$1\\|" ); - I t does not work for 4,6,7 lines/scenarios.

Please help as I have a dealine to meet.

Thanks a ton in advance.
11 years ago
Hi

Thanks for the quick reply.

In the string, each line ends with a new line - \n. Some of the lines start with TEST (which is I am after).

The string example:

aaaa^ \n
TEST^x^^y^z^""^cccc^bbb^\n
bbb
TEST^x^This is not empty so ignore the content between 5th and 6th occurence of the search cahracter^y^z^""^cccc^bbb^\n
TEST^x^This is empty and since the content between 5th and 6th occurence of the search cahracter is NOT EMPTY, Please replace this with STR^y^z^NOT EMPTY^cccc^bbb^\n

Hope this helps.

Your help is highly appreciated as I have a deadline to meet for this task.

Thanks a ton in advance.
11 years ago
ok...sorry for not the original post not be too clear.

Hope the below details are more clear and explains what I tried so far.

I have a three requirements:

1a) I have a string that contains three occurences of the word 'TEST'. Each of this word is followed by ^ and I need to check if the content between 2 and and 3rd occurence of ^ is blank, if it is blank/empty search further to see if the content between the 5th and 6th occurence of the ^ is ""
If it is "", then replace it to be blank/empty
Example:
Existing string:

aaaa^
TEST^x^^y^z^""^cccc^bbb^

Expected string:

aaaa^
TEST^x^^y^z^^cccc^bbb^

1b) If the content between 2nd and 3rd occurence of ^ is not blank and not "", then do not change the content between 5th anc 6th occurence

Existing string:


TEST^p^^q^r^""^lll^mmm^

Expected string:


TEST^p^^q^r^""^lll^mmm^
I need to repeat this logic check whenever TEST word is found.

1c) If the content between 5th and 6th occurence of ^ is not blank and not "" and if the content between 2nd and 3rd is blank/empty then replace it with STR.

Existing string:


TEST^g^^q^r^YYY^lll^mmm^

Expected string:


TEST^g^STR^q^r^YYY^lll^mmm^


I need to accomplish allt he above cases in a java regex. I could make case 1 work but not case 2 and 3.

How to accomplish case 2 and 3 in the same regex expression ( I am not sure as what the regex expressions are for not empty contnet check and for 'OR' check).
In non regex world, in plain if else approach, I can take care of the 3 cases as follows:

if (the content between 2nd and 3rd occurence of ^ is empty)
{

if(content between 5th and 6th occurence of ^ is "")
{
make this content empty
}
else
{
set the content between 2nd and 3rd occurence of ^ as STR
}


}

But since I need to make this check for each line which starts with the word TEST in the String, I am leaning towards regex.

So far the regex that works for case 1 is as follows:

str.replaceAll("(TEST\\^[^^]*\\^\\^[^^]*\\^[^^]*\\^)\"\"", "$1")

Any help is highly appreciated.

Thanks in advance.
11 years ago
Hi all,

I am new to java regex.

I have a string that has 10 lines that contains three occurences of the word 'TEST' at the beginning of some of the new lines. Each of the occurrence of the word TEST is followed by ^ and I need to check if the content between 2 and and 3rd occurence of ^ is blank, if it is blank/empty search further to see if the content between the 5th and 6th occurence of the ^ is ""
If it is "", then replace it to be blank/empty

I need to repeat this logic check whenever TEST word is found.

Example:

Existing string:



Expected string:


How do I do it.

Any help is highly appreciated.


Thanks in advance.

11 years ago
Hi all,

In our system, whenever a JMS message procesing from a queue fails due to an application exception, the message is put on a different queue (error queue). It is observed that some of the failed messages are poision messages due to bad format that need manual fix and resent to the queue. The queues are durable and have an entry in the database table for each JMS message.

What are the ways to handle poision messages - Is there a way to store the message in the error queue itself without being reprocessed by the Spring Message driven pojo (MDP) by setting any flag/status on the message/session/connection?

Or is it better to store the message in a database table for further analysis and resend the message to the queue after it is corrected?

Any ideas are highly appreciated.

Thanks in advance.
Hi all,

I have a standalone java enviornment with robust exception handling and the application is well tested.

But some times the process flow is not behaving the way it is expected.
Thus I would want to keep track of anything abnormal that might be happening by looking at the log files. I am thinking that log4j configuration might not help me to log the occurence of the java.lang.Error subclasses.

Similar to the .out files in weblogic enviornment which logs everything that happens in the JVM including the occurence of any java.lang.Error (like stackoverflow/outofmemoryerror), is there a way to capture such errors when occured in a standalone/non-J2EE enviornment?

Any help is appreciated.

Thanks in advance for your time and input.

11 years ago
Hi all,

Few basic questions:

1) How does Weblogic v923 handle recovery in the cases of java.lang.Error(OutofMemoryError/StackOverFlowError etc)?

2) In the case of a cluster enviornment, if a manged node is down due to the java.lang.Error, will the further processing be handled by a different managed node?

Appreciate your input.

Thanks in advance.
11 years ago
Hi all,

I have Spring JMS/MDPs running in a standalone/non-J2EE enviornment listening to the queue that is deployed in a J2EE enviornment.

How does Spring handle the the following scenarios:

1) where in errors like java.lang.OutofMemory errors occur while processing the message from the queue. Will the message still exist on the queue?

2) Also what happens to the message in case there is an RuntimeException thorwn while processing it and at the same time for some reason the J2EE enviornment in which the queue is present has crashed... is there a way to put the message back on the queue or is the message lost?

Any input is highly appreciated.

Thanks in advance.

Any input is highly appreciated.
Hi all,

In our production cluster enviornment we use WebLogic v923 and Java v5.

We have many queues that get high volume of messages per day.
The JMS queues are setup with redirect limit as zero and the messages are sent to error queue when they fails to be processed by these queues
s related MDB due to an application logic related exception.
All the queues including the error queues are having persistent stores which is a database table per queue.
Weblogic oracle non-xa jdbc driver is used.

This mechanism is working fine.

But now and then a strange situation is observed. On different days, 5% -10 % of the messages which failed due to an application logic exception are lost.
They are not in the persistent store table and there are no signs of the message being processed by the Message driven bean associated with the error queue.
Unfortunately the weblogic .out files were purged related to dates on which there failures happened due to disk space issues and thus unable to find the root cause.
The jms logging was not set either.
It is confirmed that those messages were processed once through the normal flow from the regular queues but failed due to an application logic related exception. It is confirmed because I see those exceptions that caused failure logged to a differnt mechanism that we have in place.

I went through weblogic jms docs and looked at different settings like expiration value of the message etc in our cluster. The current setting that we have is that the message never expires.

I also confirmed that there were no database crashes around those dates where we observed these failures.
Also we have logic in place to put the message back on error queue when there is an application exception/java.lang.Exception while processing the message from the error queue.

What could be the cause for these occassional failures? The possible reasons I could think of were as follows (but I believe that the message must have been redelivered and processed from the point of failure/recovery by weblogic, which seem not to be the case):

1) When the message is not processed due to the transaction rollback in regular queues related MDB which is due to an application exception that was thrown, something must have happened while persisting that message in the error queue related database table.
Could it be a java.lang.Error like stackoverflow/outofmemoryerror?

OR

2) Something happened after the message is persisted in error queue table but BEFORE the error queue MDB consumed it (which is highly unlikely).

OR

3) Something happened while the message is being processed from the error queue like java.lang.Error(stackoverflow/outofmemoryerror) since we do not have any redirect mechanism for the error queue...thus the failed message must have been lost??

Any input to resolve/avoid this weird issue is highly appreciated.

Thanks a ton in advance for your time and input.
When I refered to CRLF, I meant to say \r\n (return key usage) .

I tried stringxxx.replaceAll("\\r+.", "\\X000d ") for \r. But not sure how to replace only a particular \r I tried this but in vain:

stringxxx.replaceAll("|*\\r+.*|", "\\X000d ")


Any help is appreciated.

Thanks in advance.
12 years ago
Hi all,

I have a file that contains sentences separated by CRLF.
Also in each sentence, each word is seperated by | and I need to replace the words which contains CRLF with space ("")...how do I do it using regex.

File content example:

aaa|bbbb|cccCRLF
zzz|yyyCRLFxxx|nnCRLF

I need to replace CRLF with "" in the second line only ( I need to ignore the CRLF that are at the end of each sentence).

Any help is highly appreciated.

Thanks in advance.
12 years ago