user9382: I'm using Python (2.7) and its re module for recognition of various Bitcoin data, namely:  

addresses, DER sigs, OP Return hexdata, TxIDs

I've been using re.compile: for example, for a valid Tx hash (TxID):
RE_TXHASH = re.compile('^[0-9a-fA-F]{64}$')
if bool(re.match(RE_TXHASH, 'f'*64)):    # 'f'*63 would fail
    print 'valid tx hash!'
else:
    raise Exception("invalid tx hash!")

I'm looking for regex patterns for the following (or input on my current best attempt):

DER signatures: General format "30[sig_size]02[r_size]02[s_size][sighash]"
Bitcoin addresses:  re.compile('^[123mn]{1}[a-km-zA-HJ-NP-Z0-9]{26,33}$')
OP Return hex strings: re.compile('^(6a){1}[a-fA-F0-9]{0,80}$')
TxIDs: re.compile('^[0-9a-fA-F]{64}$')

EDIT: to clarify, can someone help with a regex pattern for this? "30[sig_size]02[r_size]02[s_size][sighash]"

user23123: For DER sigs, it's possible for R or S to be very small.

DER sigs: re.compile('^30[0-9a-fA-F]{72,136}02[0-9a-fA-F]{0,64}02[0-9a-fA-F]{0,64}[0-9a-fA-F]{8}')

Bitcoin addresses cannot have a 0. Also the {1} is superfluous

Bitcoin addresses: re.compile('^[123mn][a-km-zA-HJ-NP-Z1-9]{26,33}$')

Again, {1} is superfluous for OP_RETURN. Also, the a might be capitalized.

OP Return hex strings: re.compile('^6[aA][a-fA-F0-9]{0,80}$')

TXIDs are fine

9382: <p>I'm using Python (2.7) and its <code>re</code> module for recognition of various Bitcoin data, namely:  </p>

<blockquote>
  <p>addresses, DER sigs, OP Return hexdata, TxIDs</p>
</blockquote>

<p>I've been using <code>re.compile</code>: for example, for a valid Tx hash (TxID):</p>

<pre><code>RE_TXHASH = re.compile('^[0-9a-fA-F]{64}$')
if bool(re.match(RE_TXHASH, 'f'*64)):    # 'f'*63 would fail
    print 'valid tx hash!'
else:
    raise Exception("invalid tx hash!")
</code></pre>

<p>I'm looking for regex patterns for the following (or input on my current best attempt):</p>

<ol>
<li><p>DER signatures: General format <em><code>"30[sig_size]02[r_size]02[s_size][sighash]"</code></em></p></li>
<li><p>Bitcoin addresses:  <code>re.compile('^[123mn]{1}[a-km-zA-HJ-NP-Z0-9]{26,33}$')</code></p></li>
<li><p>OP Return hex strings: <code>re.compile('^(6a){1}[a-fA-F0-9]{0,80}$')</code></p></li>
<li><p>TxIDs: <code>re.compile('^[0-9a-fA-F]{64}$')</code></p></li>
</ol>

<p><strong>EDIT</strong>: to clarify, can someone help with a regex pattern for this? <em><code>"30[sig_size]02[r_size]02[s_size][sighash]"</code></em></p>
 23123: <p>For DER sigs, it's possible for R or S to be very small.</p>

<ol>
<li>DER sigs: <code>re.compile('^30[0-9a-fA-F]{72,136}02[0-9a-fA-F]{0,64}02[0-9a-fA-F]{0,64}[0-9a-fA-F]{8}')</code></li>
</ol>

<p>Bitcoin addresses cannot have a 0. Also the {1} is superfluous</p>

<ol start="2">
<li>Bitcoin addresses: <code>re.compile('^[123mn][a-km-zA-HJ-NP-Z1-9]{26,33}$')</code></li>
</ol>

<p>Again, {1} is superfluous for OP_RETURN. Also, the a might be capitalized.</p>

<ol start="3">
<li>OP Return hex strings: <code>re.compile('^6[aA][a-fA-F0-9]{0,80}$')</code></li>
</ol>

<p>TXIDs are fine</p>
