Skip to content

make methode split workable with precompiled pattern #26

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

Merged
merged 1 commit into from
Jul 30, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion src/main/java/rx/observables/StringObservable.java
Original file line number Diff line number Diff line change
Expand Up @@ -368,11 +368,36 @@ public String call(Object obj) {
* <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