From b2e87338ff60851db8326abf50555bf65b311810 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 12 May 2020 14:19:18 +0200 Subject: make regular expressions case-insensitive Most users probably don't need the capitalization, and character names always have a predefined capitalization anyway. --- src/fexpr/grammar.lalrpop | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) (limited to 'src/fexpr/grammar.lalrpop') diff --git a/src/fexpr/grammar.lalrpop b/src/fexpr/grammar.lalrpop index 1540aae..6a7a9a0 100644 --- a/src/fexpr/grammar.lalrpop +++ b/src/fexpr/grammar.lalrpop @@ -11,7 +11,7 @@ use std::collections::HashSet; use lalrpop_util::ParseError; use chrono::{DateTime, Local, TimeZone, Utc, Weekday}; -use regex::Regex; +use regex::{Regex, RegexBuilder}; grammar; @@ -85,20 +85,26 @@ PlayerPredicate: Box = { } Regex: Regex = { - =>? Regex::new(&s[1..s.len() - 1]).map_err(|error| ParseError::User { - error: FError { - location: l, - data: s.to_string(), - kind: error.into(), - } - }), - =>? Regex::new(s).map_err(|error| ParseError::User { - error: FError { - location: l, - data: s.to_string(), - kind: error.into(), - } - }), + =>? RegexBuilder::new(&s[1..s.len() - 1]) + .case_insensitive(true) + .build() + .map_err(|error| ParseError::User { + error: FError { + location: l, + data: s.to_string(), + kind: error.into(), + } + }), + =>? RegexBuilder::new(s) + .case_insensitive(true) + .build() + .map_err(|error| ParseError::User { + error: FError { + location: l, + data: s.to_string(), + kind: error.into(), + } + }), } FightOutcome: FightOutcome = { -- cgit v1.2.3