8000 make split methode workable with Pattern class by ArekCzarnik · Pull Request #25 · ReactiveX/RxJavaString · GitHub
[go: up one dir, main page]

Skip to content
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=""&g 5B32 t;
*
* @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
0