mercredi 27 juillet 2016

Regex to capture all text before { character - Objective C

How would I write a regex to capture all text before the { character but on the same line?

I tried something like the following:

pattern = @"({)";
regex = [NSRegularExpression regularExpressionWithPattern:pattern options:0 error:&error];
matches = [regex matchesInString:self options:0 range: searchedRange];
for (NSTextCheckingResult* match in matches) {
    [string addAttribute:NSForegroundColorAttributeName value:        [UIColor colorFromHexString:@"#C41A16"] range:[match range]];
}

I'm trying to style the following CSS code such that p is colored and a is colored:

p {
    color: blue;
}

a {
   color: red;
}

Aucun commentaire:

Enregistrer un commentaire