// 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"(?:\<intent\-filter\>)(\n|\s|\w|\W|\b|\B|.)*?(?:\<\/intent\-filter\>)").unwrap();
let string = "<?xml version=\"1.0\" encoding=\"utf-8\"?>
<manifest
xmlns:android=\"http://schemas.android.com/apk/res/android\"
android:versionCode=\"27\"
android:versionName=\"3.3.1\"
compileSdkVersion=\"28\"
compileSdkVersionCodename=\"9\"
package=\"xyz.omnicron.caffeinate\"
platformBuildVersionCode=\"27\"
platformBuildVersionName=\"3.3.1\">
<uses-sdk
android:minSdkVersion=\"24\"
android:targetSdkVersion=\"28\"/>
<uses-permission
android:name=\"android.permission.WAKE_LOCK\"/>
<uses-permission
android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>
<uses-permission
android:name=\"android.permission.ACCESS_NOTIFICATION_POLICY\"/>
<uses-permission
android:name=\"android.permission.FOREGROUND_SERVICE\"/>
<uses-permission
android:name=\"android.permission.INTERNET\"/>
<uses-permission
android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>
<uses-permission
android:name=\"com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE\"/>
<uses-permission
android:name=\"com.google.android.c2dm.permission.RECEIVE\"/>
<permission
android:name=\"xyz.omnicron.caffeinate.permission.C2D_MESSAGE\"
android:protectionLevel=\"signature\"/>
<uses-permission
android:name=\"xyz.omnicron.caffeinate.permission.C2D_MESSAGE\"/>
<application
android:theme=\"@2131755014\"
android:label=\"@2131689511\"
android:icon=\"@2131623936\"
android:name=\"xyz.omnicron.caffeinate.Caffeine\"
allowBackup=\"true\"
supportsRtl=\"true\"
appComponentFactory=\"android.support.v4.app.CoreComponentFactory\">
<activity
android:name=\"xyz.omnicron.caffeinate.MainActivity\">
<intent-filter>
<action
android:name=\"android.intent.action.MAIN\"/>
<category
android:name=\"android.intent.category.LAUNCHER\"/>
</intent-filter>
</activity>
<receiver
android:name=\"xyz.omnicron.caffeinate.ActionReceiver\"
android:exported=\"true\">
<intent-filter>
<action
android:name=\"xyz.omnicron.caffeinate.STOP_ACTION\"/>
</intent-filter>
</receiver>
<service
android:label=\"@2131689514\"
android:icon=\"@2131230861\"
android:name=\"xyz.omnicron.caffeinate.services.CaffeinateTileService\"
android:permission=\"android.permission.BIND_QUICK_SETTINGS_TILE\">
<meta-data
android:name=\"android.service.quicksettings.ACTIVE_TILE\"
android:value=\"false\"/>
<intent-filter>
<action
android:name=\"android.service.quicksettings.action.QS_TILE\"/>
</intent-filter>
</service>
<service
android:label=\"@2131689583\"
android:icon=\"@2131230858\"
android:name=\"xyz.omnicron.caffeinate.services.SoundProfileTileService\"
android:permission=\"android.permission.BIND_QUICK_SETTINGS_TILE\">
<meta-data
android:name=\"android.service.quicksettings.ACTIVE_TILE\"
android:value=\"true\"/>
<intent-filter>
<action
android:name=\"android.service.quicksettings.action.QS_TILE\"/>
</intent-filter>
</service>
<service
android:name=\"xyz.omnicron.caffeinate.services.CaffeinationService\"
android:exported=\"false\"/>
<activity
android:label=\"@2131689585\"
android:name=\"xyz.omnicron.caffeinate.SettingsActivity\"/>
<activity
android:label=\"A/B Testing Debug Screen\"
android:name=\"xyz.omnicron.caffeinate.ABTestingDebugActivity\">
<intent-filter>
<action
android:name=\"xyz.omnicron.caffeinate.ABTestingDebugActivity\"/>
<category
android:name=\"android.intent.category.DEFAULT\"/>
</intent-filter>
</activity>
<activity
android:theme=\"@2131755016\"
android:label=\"@2131689584\"
android:name=\"xyz.omnicron.caffeinate.CreditsActivity\"/>
<service
android:name=\"com.google.firebase.components.ComponentDiscoveryService\">
<meta-data
android:name=\"com.google.firebase.components:com.google.firebase.firestore.FirestoreRegistrar\"
android:value=\"com.google.firebase.components.ComponentRegistrar\"/>
<meta-data
android:name=\"com.google.firebase.components:com.google.firebase.analytics.connector.internal.AnalyticsConnectorRegistrar\"
android:value=\"com.google.firebase.components.ComponentRegistrar\"/>
<meta-data
android:name=\"com.google.firebase.components:com.google.firebase.iid.Registrar\"
android:value=\"com.google.firebase.components.ComponentRegistrar\"/>
</service>
<receiver
android:name=\"com.google.android.gms.measurement.AppMeasurementReceiver\"
android:enabled=\"true\"
android:exported=\"false\"/>
<receiver
android:name=\"com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver\"
android:permission=\"android.permission.INSTALL_PACKAGES\"
android:enabled=\"true\"
android:exported=\"true\">
<intent-filter>
<action
android:name=\"com.android.vending.INSTALL_REFERRER\"/>
</intent-filter>
</receiver>
<service
android:name=\"com.google.android.gms.measurement.AppMeasurementService\"
android:enabled=\"true\"
android:exported=\"false\"/>
<service
android:name=\"com.google.android.gms.measurement.AppMeasurementJobService\"
android:permission=\"android.permission.BIND_JOB_SERVICE\"
android:enabled=\"true\"
android:exported=\"false\"/>
<receiver
android:name=\"com.google.firebase.iid.FirebaseInstanceIdReceiver\"
android:permission=\"com.google.android.c2dm.permission.SEND\"
android:exported=\"true\">
<intent-filter>
<action
android:name=\"com.google.android.c2dm.intent.RECEIVE\"/>
<category
android:name=\"xyz.omnicron.caffeinate\"/>
</intent-filter>
</receiver>
<service
android:name=\"com.google.firebase.iid.FirebaseInstanceIdService\"
android:exported=\"true\">
<intent-filter
android:priority=\"-500\">
<action
android:name=\"com.google.firebase.INSTANCE_ID_EVENT\"/>
</intent-filter>
</service>
<activity
android:theme=\"@16973840\"
android:name=\"com.google.android.gms.common.api.GoogleApiActivity\"
android:exported=\"false\"/>
<provider
android:name=\"com.google.firebase.provider.FirebaseInitProvider\"
android:exported=\"false\"
android:authorities=\"xyz.omnicron.caffeinate.firebaseinitprovider\"
android:initOrder=\"100\"/>
<meta-data
android:name=\"com.google.android.gms.version\"
android:value=\"@2131361800\"/>
</application>
</manifest>
";
// 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/