Reputation: 140
Finding Java tedious after Python. Looking to parse some base64 concated data.
How do I split a simple string on one or more equals '='?
What is wrong with this simple regex? (it's Java codebase under the Jython hood)
>>> s = "hello=world"
>>> s.split("=+")
['hello=world']
>>> s.split("=*")
['hello=world']
>>> s.split("=")
['hello', 'world']
Upvotes: 2
Views: 114
Reputation: 27478
Interesting problem!
Your code is valid Java syntax for splitting.
BUT
You are using Jython and Jython string.split()
splits on character string not a regex.
You need to use the Jython re.split
to break up the string.
Upvotes: 4
Reputation: 140
Just an issue with Jython. FYI
Input
decryptKeySplits("Testing=hello");
decryptKeySplits("Testing====hello");
decryptKeySplits("Testing=hello==");
decryptKeySplits("Testing=hello=this=it");
Results
2
2
2
4
Upvotes: 0