Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. documentclass{article}
  2. usepackage{expl3}
  3.  
  4. begin{document}
  5. ExplSyntaxOn
  6.  
  7. cs_set:Npn prepare_regex:N #1 {
  8. cs_set_nopar:Npn l_tmpa_regex {
  9. __regex_branch:n {
  10. __regex_assertion:Nn c_true_bool { char`^ __regex_anchor:N l__regex_min_pos_int }
  11. __regex_class:NnnnN c_true_bool {__regex_item_caseful_equal:n {97}}{1}{-1} #1
  12. __regex_assertion:Nn c_true_bool { X __regex_break_true:w }
  13. __regex_class:NnnnN c_true_bool { use:c{__regex_prop_.:} }{0}{-1} c_false_bool
  14. __regex_assertion:Nn c_true_bool { char`$ __regex_anchor:N l__regex_max_pos_int }
  15. }
  16. }
  17. }
  18.  
  19. cs_set:Npn test_match:n #1 {
  20. #1:~
  21. regex_extract_once:NnNTF l_tmpa_regex {#1} l_tmpa_seq {}{}
  22. par
  23. }
  24. ttfamily
  25.  
  26. greedy~match: par
  27. prepare_regex:N c_false_bool
  28. test_match:n { ab }
  29. test_match:n { aab }
  30. test_match:n { aaab }
  31. test_match:n { aaaa }
  32.  
  33. medskip
  34. lazy~match: par
  35. prepare_regex:N c_true_bool
  36. test_match:n { ab }
  37. test_match:n { aab }
  38. test_match:n { aaab }
  39. test_match:n { aaaa }
  40.  
  41. ExplSyntaxOff
  42. end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement