• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

get url parts

 
Ranch Hand
Posts: 245
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Need to this(request.getHeader("referer")) to become, via string replace


what I can get is:


what about "http://"..., since this thing can be absent as I know, how to read that ?
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

what about "http://"..., since this thing can be absent as I know, how to read that ?


If it's a URL object, I think what you want is getProtocol(), but I'm not sure exactly what it returns. It might just be "http".

Winston
 
Miran Cvenkel
Ranch Hand
Posts: 245
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
nope, that thing returns "HTTP/1.1"

EDIT:
digged up a code that I made in past:



that should get me the thing, doh I don't remember what exactly that regex does (-:
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, let's analyze it with the help of java.util.regex.Pattern:
- (?<=\\?)l2=.*?& (1)
- |
- \\?l2=.*?$ (2)
- |
- &l2=.*?& (3)
- |
- &l2=.*?$ (4)

So you have part 1 or part 2 or part 3 or part 4.

Part 1 starts with a positive lookbehind of a single ?. So it's "l2=" preceded by (but not part of the match) a single ?, and followed by anything until the first & (the .*? is reluctant, stopping whenever the & is found).

Part 2 is similar: a single ? (this time part of the match), followed by "l2=", followed by anything until the end of the line ($).

I'm sure you can work out parts 3 and 4 by following the same way of thinking.
 
What kind of corn soldier are you? And don't say "kernel" - that's only for this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic