title: How to match strings of only a specific length of characters in regex? (Python)
body: <p>I'm using</p>
  
  <pre><code>\[(.*?)\]|Response code (?P&lt;code&gt;\d+)
  </code></pre>
  
  <p>to search these fields:</p>
  
  <pre><code>[2018-01-20 05:19:54.812] INFO    com.mulesoft.ch.monitoring.MonitoringCoreExtension [qtp689806602-32]: Monitoring enabled: true
  [2018-01-20 05:19:54.813] INFO    com.mulesoft.ch.monitoring.MonitoringCoreExtension [qtp689806602-32]: Registering ping flow injector...
  [2018-01-20 05:19:54.833] INFO    com.mulesoft.ch.queue.boot.PersistentQueueCoreExtension [qtp689806602-32]: The PersistentQueueManager is NOT configured. The normal VM queue manager will be used.
  [2018-01-20 05:19:54.841] INFO    org.mule.lifecycle.AbstractLifecycleManager [qtp689806602-32]: Initialising RegistryBroker
  [2018-01-20 05:19:54.872] INFO
  [2018-01-24 02:14:30.153] INFO    org.mule.routing.SynchronousUntilSuccessfulProcessingStrategy [[swt-fastsalescomp-anaplan-schedules].ScatterGatherWorkManager.24]: Exception thrown inside until-successful org.mule.module.http.internal.request.ResponseValidatorException: Response code 503 mapped as failure.
  </code></pre>
  
  <p>But I only want it to match the dates, not the other stuff that's between brackets as well as assign a named group 'code'(that parts working). I tried several variations including</p>
  
  <pre><code>\[(\d*?)\]
  \[(\W*?)\]
  \[^(\.*?){23}$\]
  </code></pre>
  
  <p>But I can't seem to get it to find anything with those criteria.</p>
  
  <p>Bonus:
  I might be able to figure this one out once the rest is solved, but I might as well ask while I'm in here. How do I update a dictionary with the date and code as a key value pair?</p>