// include the latest version of the regex crate in your Cargo.toml
extern crate regex;
use regex::Regex;
fn main() {
let regex = Regex::new(r"(?m)(?:(:\n\s))(?:\s|\n|(?:.(?!modern))*)*").unwrap();
let string = "js/modern/redux/actions/open-file-in-new-window.js:
8 import { openWindow, maybeSetVariantRedirectDomainQueryParam } from '@slack/infra/multi-window';
9: import getPrimaryView from '@slack/redux/stores/workspace-store/get-primary-view';
10 import { isGovSlack } from '@slack/utility/is-gov-slack';
26 const teamId = getTeamId(team);
27: const conversationId = getPrimaryView(state);
28 let fileUrl = teamId
js/modern/redux/actions/open-shortcuts-menu.js:
10 import looksLikeChannelId from '@slack/utility/looks-like-channel-id';
11: import getPrimaryView from '@slack/redux/stores/workspace-store/get-primary-view';
12 import jumpToMessage from '@slack/redux/actions/jump-to-message';
25 const state = getState();
26: const primaryViewId = getPrimaryView(state);
27 ";
// result will be an iterator over tuples containing the start and end indices for each match in the string
let result = regex.captures_iter(string);
for mat in result {
println!("{:?}", mat);
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Rust, please visit: https://docs.rs/regex/latest/regex/