Jump to content

Help for StringRegExpReplace


Recommended Posts

Thanks all for your help. It turned out the file to analyze was even more in disarray than I thought, even the fields were not always in the same order, so I produced a solution with many more lines of code that first chops the data into usable chunks and then pushes the data snippets individually into different variables. It works, thanks a lot for getting me on the right train folks!

Link to comment
Share on other sites

  • 3 months later...

Hi.

I need to extract from the text of two fragments that are in quotation marks. For example: bla-bla, "first fragment", and again, bla bla, "second fragment", and other text ...

result should be: first fragment and second fragment

This can be realized using StringRegExpReplace?

I got only so, but it is a lot of code.

$orig_string = 'bla-bla, "first fragment", and again, bla bla, "second fragment", and other text ...'

$string_len = StringLen ($orig_string)

$1st_pos = StringInStr ( $orig_string, '"' , 0 , 1)

$2st_pos = StringInStr ( $orig_string, '"' , 0 , 2)

$3st_pos = StringInStr ( $orig_string, '"' , 0 , 3)

$4st_pos = StringInStr ( $orig_string, '"' , 0 , 4)

$1st_string = StringTrimLeft( $orig_string, $1st_pos)

$Right_trim = $string_len - $2st_pos + 1

$1st_string = StringTrimRight( $1st_string, $Right_trim)

$2st_string = StringTrimLeft( $orig_string, $3st_pos)

$Right_trim = $string_len - $4st_pos + 1

$2st_string = StringTrimRight( $2st_string, $Right_trim)

MsgBox(0,"extract from the text..","Original: "&$orig_string&@CRLF&@CRLF&"1st: "& _

$1st_string&@CRLF&"2st: "&$2st_string)

Link to comment
Share on other sites

Thank you, but the result should be without quotes.

Me showed another solution: $arrayOFparametrs=StringRegExp($sTekst, '(?:"(.*?)")+?', 3)

The problem is solved, thanks for the help.

Edited by ynbIpb
Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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