I am in Notepad++. I have the following data embedded in a large html file. I want to get the variables before the </ix:nonNumeric> at the end of the lines, onto their own lines by themselves so the output is:

00891906 1.12.13 30.11.14 30.11.14 Company Accounts Private Limited Company


There is more data but if I can get regex to do this, I will be able to work the rest out. Thanks. Once working, I will use the Batch Replace in a directory and do this to a number of txt files.

                <ix:nonNumeric contextRef="FY_30_11_2014" name="ns7:NameAuthor" order="1" tupleRef="XBRLDocumentAuthorGrouping_Group45" xmlns:ix="http://www.xbrl.org/2008/inlineXBRL"></ix:nonNumeric>
                <ix:nonNumeric contextRef="FY_30_11_2014" name="ns7:DescriptionOrTitleAuthor" order="2" tupleRef="XBRLDocumentAuthorGrouping_Group45" xmlns:ix="http://www.xbrl.org/2008/inlineXBRL"></ix:nonNumeric>
                <ix:nonNumeric contextRef="FY_30_11_2014" name="ns7:UKCompaniesHouseRegisteredNumber" xmlns:ix="http://www.xbrl.org/2008/inlineXBRL">00891906</ix:nonNumeric>
                <ix:nonNumeric contextRef="CountriesHypercube_FY_30_11_2014_Set1" name="ns7:CountryFormationOrIncorporation" format="ixt2:nocontent" xmlns:ix="http://www.xbrl.org/2008/inlineXBRL" />
                <ix:nonNumeric contextRef="CurrenciesHypercube_FY_30_11_2014_Set2" name="ns7:PrincipalCurrencyUsedInBusinessReport" format="ixt2:nocontent" xmlns:ix="http://www.xbrl.org/2008/inlineXBRL" />
                <ix:nonNumeric contextRef="EntityOfficersHypercube_FY_30_11_2014_Set3" name="ns5:NameDirectorSigningAccounts" format="ixt2:nocontent" xmlns:ix="http://www.xbrl.org/2008/inlineXBRL" />
                <ix:nonNumeric contextRef="cfwd_30_11_2014" name="ns7:StartDateForPeriodCoveredByReport" format="ixt2:datedaymonthyear" xmlns:ix="http://www.xbrl.org/2008/inlineXBRL">1.12.13</ix:nonNumeric>
                <ix:nonNumeric contextRef="cfwd_30_11_2014" name="ns7:EndDateForPeriodCoveredByReport" format="ixt2:datedaymonthyear" xmlns:ix="http://www.xbrl.org/2008/inlineXBRL">30.11.14</ix:nonNumeric>
                <ix:nonNumeric contextRef="cfwd_30_11_2014" name="ns7:BalanceSheetDate" format="ixt2:datedaymonthyear" xmlns:ix="http://www.xbrl.org/2008/inlineXBRL">30.11.14</ix:nonNumeric>
                <ix:nonNumeric contextRef="FY_30_11_2014" name="ns7:EntityAccountsType" xmlns:ix="http://www.xbrl.org/2008/inlineXBRL">Company accounts</ix:nonNumeric>
                <ix:nonNumeric contextRef="FY_30_11_2014" name="ns7:LegalFormOfEntity" xmlns:ix="http://www.xbrl.org/2008/inlineXBRL">Private Limited Company</ix:nonNumeric>
                <ix:nonNumeric contextRef="FY_30_11_2014" name="ns7:DescriptionPeriodCoveredByReport" xmlns:ix="http://www.xbrl.org/2008/inlineXBRL">FY</ix:nonNumeric>
                <ix:nonNumeric contextRef="FY_30_11_2014" name="ns7:EntityTrading" format="ixt2:booleantrue" xmlns:ix="http://www.xbrl.org/2008/inlineXBRL">true</ix:nonNumeric>
                <ix:nonNumeric contextRef="FY_30_11_2014" name="ns7:EntityDormant" format="ixt2:booleanfalse" xmlns:ix="http://www.xbrl.org/2008/inlineXBRL">false</ix:nonNumeric>
                <ix:nonNumeric contextRef="FY_30_11_2014" name="ns5:AccountsPreparedUnderHistoricalCostConventionInAccordanceWithFRSSE" format="ixt2:booleantrue" xmlns:ix="http://www.xbrl.org/2008/inlineXBRL">true</ix:nonNumeric>
                <ix:nonNumeric contextRef="FY_30_11_2014" name="ns5:CompanyExemptFromPreparingCashFlowStatementUnderFRS1" format="ixt2:booleanfalse" xmlns:ix="http://www.xbrl.org/2008/inlineXBRL">false</ix:nonNumeric>
                <ix:nonNumeric contextRef="FY_30_11_2014" name="ns5:AccountsHaveBeenPreparedInAccordanceWithProvisionsSmallCompaniesRegime" format="ixt2:booleantrue" xmlns:ix="http://www.xbrl.org/2008/inlineXBRL">true</ix:nonNumeric>
                <ix:nonNumeric contextRef="FY_30_11_2014" name="ns5:RelatedPartyTransactionExemptionBeingClaimed" format="ixt2:booleanfalse" xmlns:ix="http://www.xbrl.org/2008/inlineXBRL">false</ix:nonNumeric>
                <ix:nonNumeric contextRef="FY_30_11_2014" name="ns6:CompanyHasActedAsAnAgentDuringPeriod" format="ixt2:booleanfalse" xmlns:ix="http://www.xbrl.org/2008/inlineXBRL">false</ix:nonNumeric>
                <ix:nonNumeric contextRef="SharesHypercube_FY_30_11_2014_Set4" name="ns7:DescriptionShareType" xmlns:ix="http://www.xbrl.org/2008/inlineXBRL">Ordinary</ix:nonNumeric>
                <ix:nonFraction contextRef="SharesHypercube_FY_30_11_2014_Set4" name="ns5:ParValueShare" unitRef="GBP" decimals="INF" format="ixt2:numdotdecimal" scale="0" xmlns:ix="http://www.xbrl.org/2008/inlineXBRL">1.00000</ix:nonFraction>
            <ix:tuple name="ns7:XBRLDocumentAuthorGrouping" tupleID="XBRLDocumentAuthorGrouping_Group45" /></ix:hidden>
            <link:schemaRef xlink:href="http://www.xbrl.org/uk/gaap/core/2009-09-01/uk-gaap-full-2009-09-01.xsd" xlink:type="simple" /></ix:references>
            <xbrli:unit id="GBP"><xbrli:measure>iso4217:GBP</xbrli:measure></xbrli:unit><xbrli:unit id="USD"><xbrli:measure>iso4217:USD</xbrli:measure>`
  • does the random contain any < and > chars too? – LPChip Jul 12 '15 at 20:02
  • Are all of your variables preceded by digitdigitdigit>? And does that pattern appear elsewhere? If the answers are "yes" and "no" then simply search for that 4 character prefix and for < as the terminator. Sorry not trying to build regexes on a mobile device. – fencepost Jul 12 '15 at 20:05
  • @LPChip Yeah, it contains : . > < ? $ ... allsorts. I don't think that matters as the expression works for ONE variable. But I need to combine the expressions to start again at the end of the first Variable found, and repeat for the next variable. Not certain on the boolean format to combine. – Jade Connor Jul 12 '15 at 20:41
  • It does matter, because if it wouldn't you could simply search for < anything > variable < anything >. But that is not the case now, making things a lot more complicated, as you'll have to start using the | operator (OR) and use a list. – LPChip Jul 12 '15 at 20:48
  • Or perhaps you should use 40 different regexes, one for each variable, and use multiple (...) patterns, refering to \1 \2 \3 accordingly. – LPChip Jul 12 '15 at 20:50

Based on the example you gave, the following regex will work:

Find what: .+?(<.+?>)(.+?)(<.+?>)

Replace with: \2\r

This will give the following result with your data:

 randomrandom random randomrandom random randomrandom  random random randomrandom random randomrandom random

Only the last line will not be filtered out, but that can be manually removed.

  • I tried that with two variables and it does give 3 lines, the first variable it on the top line, great, but the next two lines are blank! I am replacing the <.+?> with my expression yes? And leaving the (.+?) in the middle of my two expressions yes? (my expression contains a (.+?) to get the variable out of the expression)... – Jade Connor Jul 13 '15 at 20:25
  • This is driving me mad I wish I could send you a text file showing my data and show you the actual expressions and variables that I want out of it. – Jade Connor Jul 13 '15 at 20:29
  • No, you use the code provided as is. It should do it. I tested it with the example you gave and that was my output. Basically it searches for text, then the first <, then some more text, then the > and what comes then between that and the next < is your variable. – LPChip Jul 13 '15 at 20:30
  • Just a moment... – Jade Connor Jul 13 '15 at 20:35
  • I can't get this to work with my data. I am trying to find a site I can upload the text and data (~130k) to to show you... – Jade Connor Jul 13 '15 at 20:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.