|
-
May 27th, 2009, 07:48 AM
#1
Regex building
Last edited by rEnEeK; May 30th, 2009 at 12:22 PM.
-
May 27th, 2009, 08:09 AM
#2
Re: Regex building
Well - what specifically are you interested in from the string? And does the response you want to parse always look that way?
Is it only the content of the Math.Ceil you want?
-
May 27th, 2009, 08:12 AM
#3
Re: Regex building
Last edited by rEnEeK; May 30th, 2009 at 12:23 PM.
-
May 27th, 2009, 09:23 AM
#4
Re: Regex building
So you want the evaluated value from the Math.Ceil extracted?
Meaning you get (amongst other things) the string
Code:
<td>Traffic left:</td><td align=right><b><script>document.write(setzeTT(""+Math.ceil(24686696/1000)));</script> MB</b></td>
into your code, you want to pass it through a regex and display it?
Then I'd think something like this would be enough:
Code:
Dim regex As New System.Text.RegularExpressions.Regex("Math.ceil\((?<numerator>\d+)/(?<denominator>\d+)[^>]+>(?<unit>[^<]+)")
Dim match As System.Text.RegularExpressions.Match = regex.Match(str)
Dim result As String = Math.Ceiling(CInt(match.Groups("numerator").Value) / CInt(match.Groups("denominator").Value)) & match.Groups("unit").Value
This will for the above string, provide the result "24687 MB"
(remember to check for IsMatch or whether groups exists etc before trying to convert the values to integer)
Hope this helps, otherwise I've misunderstood what you wanted
-
May 27th, 2009, 09:30 AM
#5
Re: Regex building
Last edited by rEnEeK; May 30th, 2009 at 12:23 PM.
-
May 27th, 2009, 09:35 AM
#6
Re: Regex building
Strange - which code line of the ones I showed gives you the exception?
-
May 27th, 2009, 09:36 AM
#7
Re: Regex building
Dim match As System.Text.RegularExpressions.Match = regex.Match(Str)
-
May 27th, 2009, 09:40 AM
#8
Re: Regex building
str is the string you want to parse, so it must be replaced with the content you want to match on.
I think you called it responsedata earlier.
-
May 27th, 2009, 09:51 AM
#9
Re: Regex building
Thanks very much, now it works... One question again...
<script>document.write(setzeTT("315926"))</script> MB</b>
How can I write this?
315926 is generated number from webpage
-
May 27th, 2009, 09:54 AM
#10
Re: Regex building
 Originally Posted by rEnEeK
Thanks very much, now it works... One question again...
<script>document.write(setzeTT("315926"))</script> MB</b>
How can I write this?
Where, from where (and why) do you want to write it?
I'm not sure I understand the issue.
If you need to call a javascript function with that value, numerous techniques exists from using the ScriptManager, to simply a label/span or ...... but as said - I'm not sure I understand the issue.
-
May 27th, 2009, 09:56 AM
#11
Re: Regex building
Last edited by rEnEeK; May 30th, 2009 at 12:23 PM.
-
May 27th, 2009, 09:57 AM
#12
Re: Regex building
Then why not just write the result string parsed from the regex into your code? Why run it through a javascript?
-
May 27th, 2009, 10:00 AM
#13
Re: Regex building
Last edited by rEnEeK; May 30th, 2009 at 12:23 PM.
-
May 27th, 2009, 10:08 AM
#14
Re: Regex building
Well - that code is also just wrong from what I can see. You're not putting any content into the strbstorage stringbuilder and you don't seem to use the match collection.
I think you need to take it one step at the time, because either you're trying to tackle multiple things at once and not understanding the code or similar.
You have the response string which you wanted to parse through a regular expression to show traffic remaining:
Code:
<td>Traffic left:</td><td align=right><b><script>document.write(setzeTT(""+Math.ceil(24686696/1000)));</script> MB</b></td>
If you run that through the code I gave you, you'll have a string which contains "24687 MB" (I named it result in the example).
Why then not just assign that result value to your label - for example like: lblStorage.Text = result
I am really starting to not understand what you're trying to accomplish because as said - it seems like multiple different things going on and it doesn't look like you're using the code snippets I provided.
-
May 27th, 2009, 10:11 AM
#15
Re: Regex building
I tried all, but I still don't know, how can I write it... I used google, some books, but it still doesn't work..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|