Skip to content

make split methode workable with Pattern class #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 12 commits into from
33 changes: 29 additions & 4 deletions src/main/java/rx/observables/StringObservable.java
Original file line number Diff line number Diff line change
Expand Up @@ -357,22 +357,47 @@ public String call(Object obj) {

/**
* Rechunks the strings based on a regex pattern and works on infinite stream.
*
*
* <pre>
* split(["boo:an", "d:foo"], ":") --> ["boo", "and", "foo"]
* split(["boo:an", "d:foo"], "o") --> ["b", "", ":and:f", "", ""]
* </pre>
*
*
* See {@link Pattern}
* <p>
* <img width="640" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/St.split.png" alt="">
*
*
* @param src
* the source that should be use for the split
* @param regex
* a string that build regular expression modifier
* @return the Observable streaming the split values
*/

public static Observable<String> split(final Observable<String> src, String regex) {
final Pattern pattern = Pattern.compile(regex);
Pattern pattern = Pattern.compile(regex);
return StringObservable.split(src,pattern);
}

/**
* Rechunks the strings based on a regex pattern and works on infinite stream.
*
* <pre>
* split(["boo:an", "d:foo"], ":") --> ["boo", "and", "foo"]
* split(["boo:an", "d:foo"], "o") --> ["b", "", ":and:f", "", ""]
* </pre>
*
* See {@link Pattern}
* <p>
* <img width="640" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/St.split.png" alt="">
*
* @param src
* the source that should be use for the split
* @param pattern
* pre compiled regular expression pattern for the split functionality
* @return the Observable streaming the split values
*/
public static Observable<String> split(final Observable<String> src, final Pattern pattern) {

return src.lift(new Operator<String, String>() {
@Override
Expand Down