Answers.Body: <p>the regex pattern should be</p>
  <pre><code>search(r&quot;(\d+),(\d+)\]*\.avi$&quot;, f)
  </code></pre>
  <p>previously, the pattern is &quot;13445&quot; + &quot;.avi&quot;
  now, the pattern is &quot;13445&quot; + &quot;]&quot; + &quot;.avi&quot;, and it should be fine with or without square brackets.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-04T05:34:06.630Z
Answers.LastActivityDate: 2020-11-04T05:34:06.630Z
Answers.UserDisplayName: xer-rex
Body: <p>I have a code it work with fine with with file name does not contain square bracket []</p>
  <p>an example:
  <strong>10245,13445.avi</strong></p>
  <pre><code>def insert_types(out, dir):
  for root, dirs, files in walk(dir):
     for f in os.listdir(dir):
          match =  search(r&quot;(\d+),(\d+)\.avi$&quot;, f)
          if match:
              startframe = match.group(1)
              endframe = match.group(2)
              out = fvf.InsertSign(out, join(root, f), int(startframe), int(endframe), matrix=&quot;709&quot;)
  return out
  </code></pre>
  <p>This code works with <code>.avi</code> file format and it take the first and the second values with the comma mark <code>,</code>  and its only work with the filename which does not contain square bracket like  <code>10245,13445.avi</code>
  But now I want to make this code ignore the square bracket [] in file name <code>[10245,13445].avi</code>  how it gonna be, any help?</p>
  <p>Thanx in advance</p>
  
Tags: <video><video-editor>
Title: How to make python ignore square bracket?
UserDisplayName: AL-KOON
ThreadText: # How to make python ignore square bracket?
  
  (Asked by: username_0 on 2020-11-03)
  
  I have a code it work with fine with with file name does not contain square bracket []
  
  an example:
  **10245,13445.avi**
  
  ```
  def insert_types(out, dir):
  for root, dirs, files in walk(dir):
     for f in os.listdir(dir):
          match =  search(r"(\d+),(\d+)\.avi$", f)
          if match:
              startframe = match.group(1)
              endframe = match.group(2)
              out = fvf.InsertSign(out, join(root, f), int(startframe), int(endframe), matrix="709")
  return out
  
  ```
  
  This code works with `.avi` file format and it take the first and the second values with the comma mark `,` and its only work with the filename which does not contain square bracket like `10245,13445.avi`
  But now I want to make this code ignore the square bracket [] in file name `[10245,13445].avi` how it gonna be, any help?
  
  Thanx in advance
  
  **Tags:** video, video-editor
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-11-04. Score: 1 | Accepted answer
  
  the regex pattern should be
  
  ```
  search(r"(\d+),(\d+)\]*\.avi$", f)
  
  ```
  
  previously, the pattern is "13445" + ".avi"
  now, the pattern is "13445" + "]" + ".avi", and it should be fine with or without square brackets.
  
  
  ---
  
  