<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://regexadvice.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Construction Advice</title><link>http://regexadvice.com/forums/68/ShowForum.aspx</link><description>&lt;P&gt;Find help building expressions to suit your needs. Consult the &lt;A href="http://regexlib.com"&gt;Regular Expression Library&lt;/A&gt; to find many pre-built expressions, and add your own once you've solved your construction problem in our forum.&lt;/P&gt;</description><dc:language>en</dc:language><generator>CommunityServer 2.1 (Build: 60809.935)</generator><item><title>Re: How to isolate bits</title><link>http://regexadvice.com/forums/thread/84585.aspx</link><pubDate>Mon, 30 Jan 2012 22:50:44 GMT</pubDate><guid isPermaLink="false">d291b357-6366-4006-9008-4266c301325a:84585</guid><dc:creator>Aussie Susan</dc:creator><slash:comments>0</slash:comments><comments>http://regexadvice.com/forums/thread/84585.aspx</comments><wfw:commentRss>http://regexadvice.com/forums/commentrss.aspx?SectionID=68&amp;PostID=84585</wfw:commentRss><description>&lt;p&gt;Can you please let us know the regex variant you are using - they are not all the same and provide different capabilities and syntax extensions?&lt;/p&gt;&lt;p&gt;Also, am I right in assuming that by &amp;quot;bit&amp;quot; you are referring to the &amp;quot;0&amp;quot;s and &amp;quot;1&amp;quot; in the first part of your input line before the first &amp;quot;=&amp;quot; character (the part that looks like a binary sum)? If so, am I right in assuming that the bits are counted from the left (and not the right within each value as would normally be the case; from least significant to the most significant)? Perhaps an example of the values you would expect to have captured in the &amp;quot;var1&amp;quot; , var2&amp;quot; etc would help.&lt;/p&gt;&lt;p&gt;Having said all that, I&amp;#39;m not sure that you can do what you are asking (or what I think you are asking) for directly within the regex. The reason is that you cannot skip characters within a capture group and I think you are wanting the spaces and &amp;quot;+&amp;quot; characters to not be included.&lt;/p&gt;&lt;p&gt;Remember that a regex pattern works on characters and has absolutely no understanding of numbers or separators and similar classifications that we (people) may apply automatically.&lt;/p&gt;&lt;p&gt;You could use something like:&lt;/p&gt;&lt;p&gt;^(\d{4})\s+(\d)(\d)(\d{2})\D+(\d{4})\s+(\d{4})\D+(\d{3})(\d)\s+(\d{4})&lt;/p&gt;&lt;p&gt;and then use match group #1 to construct &amp;quot;var1&amp;quot;, match group #2 to make &amp;quot;var2&amp;quot;, and match group #3 for &amp;quot;var3&amp;quot;. &amp;quot;var4&amp;quot; will need to be made from the concatenation of match groups #4, #5, #6, and #7, and &amp;quot;var5&amp;quot; will be the concatenation of match groups #8 and #9.&lt;/p&gt;&lt;p&gt;As I said, the pattern has to account for every character in the match, including the spaces and other non-digit characters. However, the above regex plus some string concatenation will give you the strings that you are after.&lt;/p&gt;&lt;p&gt;An alternative is to do a bit of string manipulation first to get rid of all non-digit characters (or even non-&amp;quot;0&amp;quot; and &amp;quot;1&amp;quot; characters) and the use a regex to process the resulting string of binary digits.&lt;/p&gt;&lt;p&gt;Of course, this all assumes that the actual layout of the string is always exactly as you have given in your single example.&amp;nbsp;&lt;/p&gt;&lt;p&gt;If that is the case, then you may be better of using standard string operations: 1) replace all non-digits with a null and then 2) use the sub-string functions directly on the resulting string. This will probably be faster and have a smaller memory footprint (unless the regex library is being used elsewhere in the program).&lt;/p&gt;&lt;p&gt;Susan &lt;br /&gt;&lt;/p&gt;</description></item><item><title>How to isolate bits</title><link>http://regexadvice.com/forums/thread/84584.aspx</link><pubDate>Mon, 30 Jan 2012 16:37:55 GMT</pubDate><guid isPermaLink="false">d291b357-6366-4006-9008-4266c301325a:84584</guid><dc:creator>zallz</dc:creator><slash:comments>0</slash:comments><comments>http://regexadvice.com/forums/thread/84584.aspx</comments><wfw:commentRss>http://regexadvice.com/forums/commentrss.aspx?SectionID=68&amp;PostID=84584</wfw:commentRss><description>&lt;p&gt;Hi&lt;/p&gt;&lt;p&gt;I want to extract bits out of my regex string.&lt;/p&gt;&lt;p&gt;Here&amp;#39;s what I want to do :&lt;/p&gt;&lt;p&gt;input string : 0001 0001 + 0010 0010 + 0011 0011 = &amp;nbsp;0x11 + 0x22 + 0x33 = &amp;quot;173451&amp;quot;&lt;/p&gt;&lt;p&gt;var1 is the first 4 bits;&lt;/p&gt;&lt;p&gt;var2 is the 5th bit;&lt;/p&gt;&lt;p&gt;var3 is the 6th bit;&amp;nbsp;&lt;/p&gt;&lt;p&gt;var4 is the following 13 bits;&lt;/p&gt;&lt;p&gt;var5 is the last 5 bits.&lt;/p&gt;&lt;p&gt;Thank you&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>