Jump to content

Recommended Posts

Posted

I have a text

  Quote

===> Caption
1. first enumerated string

2. second enumerated string

....

x. "x-th" enumerated string

some other text

 

How to get this all enumerated string or entire lines ?

Remarks

first line which not start with number ends the enumeration

eace enumerated string is single line (no other line beetwen enumeration)

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Not sure to understand your request...

#Include <Array.au3>

$sContent = "1. first enumerated string" & @CRLF & _
            "2. second enumerated string" & @CRLF & _
            "3. third enumerated string" & @CRLF & _
            "4. fourth enumerated string" & @CRLF & _
            "5. fifth enumerated string" & @CRLF & _
            "some other text"

$aEnum = StringRegExp( StringRegExpReplace($sContent, "(?s)\R\D.*", ""), "(?m)^\d[\h.]*(\N+)", 3)

_ArrayDisplay($aEnum)

Do you need the number to be include to the result ?

Posted

Works well

No I do not need the numbers.

But such example would be interesting for learning.

Thanks

mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

or this...???

#Include <Array.au3>

$sContent = "1. first enumerated string" & @CRLF & _
            "2. second enumerated string" & @CRLF & _
            "3. third enumerated string" & @CRLF & _
            "4. fourth enumerated string" & @CRLF & _
            "5. fifth enumerated string" & @CRLF & _
            "some other text"

$aEnum = StringRegExp($sContent, "\d+\N+", 3)

_ArrayDisplay($aEnum)

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Posted (edited)

@mikell & kylomas : did you read the remarks in the first message ? ^_^

  On 1/16/2015 at 12:40 PM, mLipok said:
Remarks

first line which not start with number ends the enumeration

eace enumerated string is single line (no other line beetwen enumeration)

 

The text could be something like this :

$sContent = "1. first enumerated string" & @CRLF & _
            "2. second enumerated string" & @CRLF & _
            "3. third enumerated string" & @CRLF & _
            "4. fourth enumerated string" & @CRLF & _
            "5. fifth enumerated string" & @CRLF & _
            "some other text" & @CRLF & _
            "6. sixth enumerated string"

So if I understand the original post, the sixth element should not be part of the return...

Edited by jguinch
Posted
  On 1/16/2015 at 8:13 PM, jguinch said:

@mikell & kylomas : did you read the remarks in the first message ? ^_^

 

The text could be something like this :

$sContent = "1. first enumerated string" & @CRLF & _
            "2. second enumerated string" & @CRLF & _
            "3. third enumerated string" & @CRLF & _
            "4. fourth enumerated string" & @CRLF & _
            "5. fifth enumerated string" & @CRLF & _
            "some other text" & @CRLF & _
            "6. sixth enumerated string"

So if I understand the original post, the sixth element should not be part of the return...

You understand it good.

btw.

I forget to say the enumeration starts with this caption.

  Quote

 

===> Caption

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...