[wplug] Regex help?
Doug Green
diego96 at mac.com
Mon Apr 27 17:19:17 EDT 2015
This (perl) is too cool. I gotta learn some of that. Someday. Wishful thinking, but it IS on my todo list. Very nice, and thank you all for the help. I've got a great starting point and will undoubtedly spend the rest of my evening trying to learn from and pick apart the supplied regular expressions.
Many thanks!
-D
> On Apr 27, 2015, at 1:52 PM, Michael Skowvron <michaels at penguincentral.org> wrote:
>
> This may also do what you need
>
> perl -nle '($numbers, $text) = $_ =~ /^([\d\.]+) (.*)$/; print $numbers,",
> ",$text' < infile > outfile
>
>
>
>> On Mon, Apr 27, 2015 at 3:35 PM, Chris Clonch <cclonch at gmail.com> wrote:
>>
>> I've had good luck with http://www.regexr.com/ for testing regex's.
>>
>> /([0-9]*)[0-9]\./ will match any series of numbers ending in a period.
>>
>> -Chris
>>
>>> On Mon, Apr 27, 2015 at 3:01 PM, Doug Green <diego96 at mac.com> wrote:
>>>
>>> Hi all,
>>> I've got some work data that I'm trying to clean up. It's a single column
>>> of Excel data, each row contains a chapter/section/subsection/paragraph
>>> number followed by a string of text. I'd like to separate the heading
>>> numbers into a different column than the body of the text (creating a two
>>> column data set).
>>>
>>> My plan was to do a CSV export, then add a comma after the number. By
>>> re-importing the CSV this <should> put the section number in a different
>>> column than the text. Example:
>>>
>>> 7.1.3.2. Section describing general attributes of an item.
>>>
>>> Converted to:
>>>
>>> 7.1.3.2., Section describing...
>>>
>>> Emacs has a convenient replace-regex function that simply asks first what
>>> regex you want to search for and next what you want to replace it with.
>>> I've tried every combo of "[0-9]\." and "[:digit:]\." but I'm not
>> matching
>>> ANY results. Can anyone point me in the right direction for a little help
>>> on writing a generalized regex that will match "any number followed by a
>>> period, optionally followed by up to 3 more numbers each followed by
>>> periods"? Clear as mud, right?
>>>
>>> Thanks!
>>> _______________________________________________
>>> wplug mailing list
>>> wplug at wplug.org
>>> http://www.wplug.org/mailman/listinfo/wplug
>> _______________________________________________
>> wplug mailing list
>> wplug at wplug.org
>> http://www.wplug.org/mailman/listinfo/wplug
> _______________________________________________
> wplug mailing list
> wplug at wplug.org
> http://www.wplug.org/mailman/listinfo/wplug
More information about the wplug
mailing list