fayeed/flutter_parsed_text

Extra space after match

peekpt opened this issue · 8 comments

Another question how can I add case insensitive to a pattern? Thank you

You need to use regexOptions parameter, by default it sets regex as case sensitive you can set to insensitive like so:

ParsedText(
  pattern: "YOUR_PATTERN",
  regexOptions: RegexOptions(
    caseSensitive: false,
  )
)

And also make sure you are using version 1.2.2.

Thank you for adding regexOptions:

The white space is still showing thought.
Captura de ecrã 2019-09-08, às 09 55 57

Another possible bug:

Empty string pattern (non null) is currently Matching all the text.
For variable patterns like this example, is it possible to return the original unmodified text?

var returningText = ( pattern.isEmpty || pattern == null ) ? matchedText : originalText;

My bad actually I changed how the package works in version 1.2.0 and forgot to remove the white spaces from the previous implementation it should work now. Try version 1.2.3

yes it's working now! Is it possible to fix the empty string?

As you can see I have to make a workaround for this by inserting a unmatchable pattern:
final pattern = query.isNotEmpty ? query : 'sadaaDSADASD';

Captura de ecrã 2019-09-08, às 11 17 05

but if I return an empty string
final pattern = query.;
Captura de ecrã 2019-09-08, às 11 15 17

Well, actually I was going to give you the same the solution that you came up with.

Anyway, the reason I think it would be a bad idea to return the original text when the pattern is empty is that how regex work and your case is pretty specific and it would create confusion for others who might except this behavior.

Fair enough ,thank you for your help