Showing results for 
Show  only  | Search instead for 
Did you mean: 

What is the regex to exclude the UPPER Case word from a sentence?


I have created a BT which gives errors as output.There are few errors that includes names of people which is in uppercase.Apart from this I have other errors too. I want to remove this name from my ouput and group them together. I want a regex which excludes all uppercase words from sentences.
my output is somethinf like this as shown below.

Given for XXX.Given for XXX.2
Given for YYY.Given for YYY.2
Given for ZZZ.Given for ZZZ.2
Other error4

In the above each name is considered as a seperate count.
I want it to be grouped and hence i need to remove the names from the output.
I need the output to be



Given for .Given for.


Other error4

I have used the below regex

(.* for) [A-Z\s]+.(.* for) [A-Z\s]+. |(.*)

Now my error is grouped and I am getting the other errors too...
but if the grouped error occurs...then I am getting like

Given for .Given for.null6
null.Other error4

since in regex I have given 2 conditions in regex if one condition is true it returns null for other and vice versa.
Why is the null being displayed and how can I get rid of this?

Can someone help me on this?


Dynatrace Leader
Dynatrace Leader

Not sure all of what's going on in the regex you tried as there seems to be a lot of unnecessary stuff, but I usually trial and error it which I can't do with yours. But what might be a better starting place is the below:

(Given for) [A-Z]+\.

Which says pull the text "Given for" from the match and match the capitals followed by a period but don't use them in the group. I expect it will be a lot easier if you don't care about the second "Given for".


Hi James K.,
Thanks for your reply...actually given for is not exactly the phrase which will come before XXX. The sentence may vary..that is the reason I have used (.* for)followed by [A-Z\s]+.
I have 2 conditions in my regex and if 1 condition is true it returns null in the place of other condition...I don't know why it is showing Null in that place. Can you please help me on this?