0

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

etc.

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.

If someone can solve the above and show the Notepad++ Find&Replace regex input to do so, I should be able to crack it. This is driving me insane.

To see the full data and the expressions I have written to try and get the variables out of it, see this txt file: http://www.filedropper.com/jaderaw

Below is the main portion of the data if someone can solve the below for a notepad++ find and replace and show me that would be great.

Thanks

            `<ix:hidden>
                <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>
            <ix:references>
            <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>
            <ix:resources>
            <xbrli:unit id="GBP"><xbrli:measure>iso4217:GBP</xbrli:measure></xbrli:unit><xbrli:unit id="USD"><xbrli:measure>iso4217:USD</xbrli:measure>`
  • 1
    Regex doesn't delete or transform anything. it simply allows you to determine what matches and what doesn't. you will have to use a program like sed/awk or write code to actually change anything. look for ways you can split the data into chuncks, preferably deliniated by your expressions starts and ends. then check whether each chunck matches the regex and keep only the matching strings. – Frank Thomas Jul 13 '15 at 20:23
  • I have updated the original post on the link by LPChip above, this time showing the actual data I am using. I am using Notepad++ to Replace, I will eventually be replacing the data in many files in a directory. Please see link above as it gives the actual data I am using. I need someone to write a regex to get the desired output explained. – Jade Connor Jul 13 '15 at 21:21
  • See, part of the problem is that you are using a fine/replace algorithm when you really need an extraction algorithm, which N++ doesn't provide by default, so there are no "results" as it were. N++ just highlights or replaces text that matches the expression. Perhaps there is a N++ plugin that will give you that functionality. otherwise consider a script approach. – Frank Thomas Jul 14 '15 at 11:51
  • If its XML data, why not use XPATH or XLST? – Frank Thomas Jul 14 '15 at 18:18
  • SU isn't the site to hire people to write Regex patterns for you. You should try using a site like Debuggex to figure out what Regex pattern will do what you need: debuggex.com/r/Su3W9RkG3by7ZlZt – Dane Jul 16 '15 at 19:38
1

First, to combine a set of independent regexs, just use the Alternation character ( | ) character between them, meaning "this expr OR than expr". for example:

expr1 = "^[a-z]+"
expr2 = "^[0-9]+"
combinedexpr = "^[a-z]+ | ^[0-9]+" 

The combinedexpr would match any string that started with a lower case letter OR a number.

As for NPP, Usually the regex find method is used with the replace option, so you essentially want to invert your regexes so that they return all strings that are NOT the expressions you want, and you will then replace them with nothing, leaving only the strings you are interested in.

If you are really needing to do this to multiple files, consider crafting a script in python or powershell or whatever, so you can control the inputs and outputs, or to get around the awkwardness of inverting your regexes simply because NPP's search is related to find/replace. You may also be able to find a NPP plugin that allows you to extract specified matches, but it is not a standard feature.

Check out this article on how to use a powershell script in windows to extract regex matches from a specified file: http://www.gfi.com/blog/windows-powershell-extracting-strings-using-regular-expressions/

Good luck

  • I have updated the original post with the actual data I am using. Please could you write a notepad++ regex to solve to show output, for the example above? – Jade Connor Jul 14 '15 at 18:01
  • We don't write peoples code here, we just help with technical approaches. And as I've said in my comments and answer, Notepad++ is the wrong tool for your usecase. it will not do what you want. – Frank Thomas Jul 14 '15 at 18:20
  • I've worked out a workaround at the moment. I am having to do it in bulk replace using one regex at a time. Thanks. – Jade Connor Jul 14 '15 at 21:10
  • I tried the bar operator, but it isn't returning all the variables I tried the return switches \2\r but it will only return the variables from the first expression, nothing from the later, combined expressions. – Jade Connor Jul 16 '15 at 19:43
  • try using parens around the each of the expressions with the pipes between the parentiesied terms. – Frank Thomas Jul 16 '15 at 20:12

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