B4J Question Get parameter

Discussion in 'B4J Questions' started by aaronk, May 23, 2015.

  1. aaronk

    aaronk Well-Known Member Licensed User

    Hi,

    I have a string and I am trying to get split part of it..

    My string is: ...?page=abc123

    I am trying to get just the abc123 part of the string.
    (The ... at the start of the string can change so I can't really use the substring function)

    Anyone know how to do this ?
     
  2. rboeck

    rboeck Well-Known Member Licensed User

    Look for the position of "?page=" with

    Code:
    Po = String.IndexOf("?page=") + 6 ' Len of Searchstring
    NewString=String.SubString(Po)
     
  3. inakigarm

    inakigarm Well-Known Member Licensed User

    If abc123 is always there (at the end of string) is easy, you've to code a right function with substring or use Right with jstringfunction taking 6 characters long from string (abc123)
     
  4. narek adonts

    narek adonts Well-Known Member Licensed User

    Is this a url post for php script?
     
  5. aaronk

    aaronk Well-Known Member Licensed User

    Hi,

    I think I have worked it out and I think this code is going to work:

    Code:
    Dim mystring As String = "pageid=abc123"
        
    Dim parameter() As String = Regex.Split("pageid=", mystring)  
        
    Log(parameter(1))
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    If you are implementing a server then you can use req.GetParameter.
     
  7. aaronk

    aaronk Well-Known Member Licensed User

    I just tried that and it worked perfect!
    Thanks heaps
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice