0

I have a string which can be presented in different forms in different files for e.g.

  1. #proxy_set_header test $flag; // no space between # & proxy_set_header
  2. # proxy_set_header test $flag; // space between # & proxy_set_header can be 1 or more
  3. proxy_set_header test $flag; // no #

Is there way to use regex in python to capture the part of the string that I am interested in proxy_set_header test $flag, which takes into account the cases that I have listed above.

chumbaloo
  • 543
  • 4
  • 13
  • 4
    what did you try? Do you know how to use `+` and/or `*` in regex ? – furas Oct 28 '20 at 06:18
  • You can do this with indices of string as well instead of using regex. Just, write a condition to check whether there is any `#` or space in the beginning of the expression or not. – Pooria_T Oct 28 '20 at 06:45
  • Looks like you are looking to create a regex, but do not know where to get started. Please check [Reference - What does this regex mean](https://stackoverflow.com/questions/22937618) resource, it has plenty of hints. Also, refer to [Learning Regular Expressions](https://stackoverflow.com/questions/4736) post for some basic regex info. Once you get some expression ready and still have issues with the solution, please edit the question with the latest details and we'll be glad to help you fix the problem. – Wiktor Stribiżew Oct 28 '20 at 08:28

0 Answers0