// 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"translate\(\'([^)]*)\',").unwrap();
let string = "<div class=\"row\">
<div class=\"col-md-12\">
<div class=\"content-title\"><?php echo $this->translate('Contattaci'); ?></div>
<?php if ( $this->messageProcessed && $this->sendError ): ?>
<div class=\"alert alert-danger\">
<h4><span class=\"glyphicon glyphicon-exclamation-sign\"></span> <?php echo $this->translate('Errore Invio Messaggio'); ?></h4>
<?php echo $this->translate('Spiacenti, si é verificato un errore durante l’invio del messaggio'); ?>.
<p class=\"error\"><?php echo $this->sendError; ?></p>
</div>
<?php elseif ( $this->messageProcessed & !$this->sendError ): ?>
<div class=\"alert alert-success\">
<h4><span class=\"glyphicon glyphicon-ok-circle\"></span> <?php echo $this->translate('Messaggio Inviato'); ?></h4>
<?php echo $this->translate('Grazie per il tuo messaggio. Risponderemo nel piú breve tempo possibile'); ?>.
</div>
<?php else: ?>
<div class=\"well well-sm\">
<?php echo $this->translate('Compila il modulo seguente per inviarci un tuo messaggio.'); ?><br />
<?php echo $this->translate('Sarà nostra premura rispondere nel minor tempo possibile per fornirti tutte le informazioni di cui puoi necessitare.'); ?>
</div>
<?php if ( $this->getSetting('site_phone') ): ?>
<div class=\"alert alert-info alert-dismissable\">
<button aria-hidden=\"true\" data-dismiss=\"alert\" class=\"close\" type=\"button\">×</button>
<span class=\"glyphicon glyphicon-info-sign\"></span> <?php echo $this->translate('Se preferisci, puoi contattarci telefonicamente al numero <b>%s</b>', $this->getSetting('site_phone')); ?>
</div>
<?php endif; ?>
<div class=\"contact-form\">
<?php echo $this->form; ?>
<div class=\"clearfix\"></div>
<p> </p>
<div class=\"small text-justify well well-sm\">
<?php echo $this->translate('I dati personali saranno trattati ai sensi del D.Lgs. 196/2003, sulla tutela delle persone e di altri soggetti rispetto al trattamento dei dati personali, il trattamento delle informazioni che ti riguardano, sarà improntato ai principi di correttezza, liceità e trasparenza e tutelando la tua riservatezza e i tuoi diritti.'); ?>
</div>
</div>
<?php endif; ?>
</div>
</div>
";
// 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/