I am trying to use RegEx to read some text from Bible commentaries which some of them have many quotations and references inside parenthesis (one of these commentaries for example backs just about everything he says with Bible paragraphs inside parentheses, which is good theologically, but for purposes of reading and enjoying some morning walking is not). Thus, I’d like to ignore them (whatever is inside parentheses) when I am listening to the many texts (I will follow them later if I need to).
This is an example of the text I am just making out right now for illustration:
The Bible teaches clearly that God loves the whole world (See: John 3:16 and OtherBibleBook 1:3-7,9), not just Israel.
I’d like to hear only the following phrase when playing the app:
The Bible teaches clearly that God loves the whole world, not just Israel.
What is the “pattern” I need to enter? (All those weird characters that mean something to programmers but nothing to me). I am using an Android app called @Voice Aloud.
If you can change the text, or the code, or input a regEx, what you're asking for is quite doable!
CHANGE THE TEXT OR THE CODE
You would need to use something like this :
String s = "The Bible teaches clearly that God loves the whole world (See: John 3:16 and OtherBibleBook 1:3-7,9), not just Israel."
string.replaceAll("\\(.*?\\)", "");
//ouput : The Bible teaches clearly that God loves the whole world , not just Israel.
INPUT A REGEX
The regex here is \(.*?\)
. You can check here that it matches everything in parentheses. You can then use a substition pattern to remove it. Depending on the flayour of regexes the app uses, you'll probably have to use a specific thing - since Android is in Java, it would ask you only for the replacement String : "".
If you want to remove the space before the parentheses, you can do this regex instead :
\s{0,1}\(.*?\)
Or in the Java code :
string.replaceAll("\\s{0,1}\\(.*?\\)","");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With