Problem Getting Strings

  • (2 Pages)
  • +
  • 1
  • 2

20 Replies - 629 Views - Last Post: 14 February 2013 - 05:44 PM Rate Topic: -----

#16 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2267
  • View blog
  • Posts: 9,479
  • Joined: 29-May 08

Re: Problem Getting Strings

Posted 14 February 2013 - 03:46 PM

View PostLilGhost, on 14 February 2013 - 11:31 PM, said:

Whole point is to take the individual characters from inside strings only & convert them to an integer array. Each string would have its own array (array1, array2, array3, etc) that would be converted on run time into a string.


Huh!?

Why not just keep them strings?
Why do the need to be integer arrays?

"DEAD" -> { {68},{69},{65}, {69}} ASCII

Or am I missing something about your intentions?
Was This Post Helpful? 0
  • +
  • -

#17 andrewsw  Icon User is offline

  • It's just been revoked!
  • member icon

Reputation: 3608
  • View blog
  • Posts: 12,393
  • Joined: 12-December 12

Re: Problem Getting Strings

Posted 14 February 2013 - 03:56 PM

Here is a lovely expression:

Dim r As New Regex("""[^""]*""")

Was This Post Helpful? 0
  • +
  • -

#18 andrewsw  Icon User is offline

  • It's just been revoked!
  • member icon

Reputation: 3608
  • View blog
  • Posts: 12,393
  • Joined: 12-December 12

Re: Problem Getting Strings

Posted 14 February 2013 - 04:01 PM

Or

Dim r As New Regex("(?<="").+(?="")")

if you want to exclude the quotes.

Erm.. I haven't actually tested this yet :)
Added: This second one isn't working..

Mmm this is, as I suspected, more complicated than it appears.

"Quote this", and "this!"
the phrase ', and ' also appears between quotes! Requires a bit more effort :)

This post has been edited by andrewsw: 14 February 2013 - 04:23 PM

Was This Post Helpful? 0
  • +
  • -

#19 andrewsw  Icon User is offline

  • It's just been revoked!
  • member icon

Reputation: 3608
  • View blog
  • Posts: 12,393
  • Joined: 12-December 12

Re: Problem Getting Strings

Posted 14 February 2013 - 04:30 PM

Dim r As New Regex("(?:"")([^""]*)(?:"")")

I would then use Replace() to get rid of the quotes, if required :) - but they shouldn't be captured.

This post has been edited by andrewsw: 14 February 2013 - 04:39 PM

Was This Post Helpful? 0
  • +
  • -

#20 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2267
  • View blog
  • Posts: 9,479
  • Joined: 29-May 08

Re: Problem Getting Strings

Posted 14 February 2013 - 04:43 PM

andrewsw: vb.net is an absolute rebel when comes parsing especially when it comes to parsing via regexs. Take the syntax highlighter use here on DIC

Keywords can be used a identifiers.
< has multiple meanings not just the commonly thought as less-than.
Quote marks are comments marker and also allowed comments
' <-Comment Don't forget
" This shouldn't result in a comment "


It has XML Literals which follow different grammar rules.

Here is a link to an old example of mine at an attempt.

The only way is to write a parser which understands the quirks of the language. Eric Lippert (former developer of the vb and vb.net language) has released an example somewhere on the web.

There are links and downloads of the vb.net grammar some where on DIC.

This post has been edited by AdamSpeight2008: 14 February 2013 - 04:58 PM

Was This Post Helpful? 1
  • +
  • -

#21 LilGhost  Icon User is offline

  • D.I.C Head

Reputation: 8
  • View blog
  • Posts: 98
  • Joined: 12-October 12

Re: Problem Getting Strings

Posted 14 February 2013 - 05:44 PM

View PostAdamSpeight2008, on 14 February 2013 - 03:46 PM, said:

View PostLilGhost, on 14 February 2013 - 11:31 PM, said:

Whole point is to take the individual characters from inside strings only & convert them to an integer array. Each string would have its own array (array1, array2, array3, etc) that would be converted on run time into a string.


Huh!?

Why not just keep them strings?
Why do the need to be integer arrays?

"DEAD" -> { {68},{69},{65}, {69}} ASCII

Or am I missing something about your intentions?


Long story.

View Postandrewsw, on 14 February 2013 - 04:30 PM, said:

Dim r As New Regex("(?:"")([^""]*)(?:"")")

I would then use Replace() to get rid of the quotes, if required :)/> - but they shouldn't be captured.

i was using .Replace, but i need to make sure that the captured strings are identical to the original ones. Because some of the strings in some of the source codes i'll be using to convert with this use regex. And so if the regex expression is wrong on the converted code, the whole code is wrong. Anyways, thanks for your help and i'll take a look at that!
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2