Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

General Discussions

Discuss any topics that are not product-specific here.

Extract web site from a string of Characters

lbolin
8 - Asteroid

I am trying to extract the web site from string charaters like this one. I just need the www.unlcetimsfoodtruck.com 

 

.  /biz_redir?url=http%3A%2F%2Fwww.uncletimsfoodtruck.com&cachebuster=1661896748&website_link_type=website&src_bizid=_3tyFt-G2ppSVIcRS86PCA&s=39567495988d1cd59560a14cf9607bb632eb94197fc1968b9d85565929d2880a

act 

 

I have several like this and they are not all the same. 

 

Is there a way to extract everything starting at www. and ending at .com

11 REPLIES 11
ahmnab00
5 - Atom

Create an ArrayList in Java and compile the regular expression using Pattern. Match the given string with the regular expression. Find the substring from the first index of the match result to the last index of the match result and add this substring to the list. See an example Why you need motorcycle- TPMS here. 

Steferd
5 - Atom

 

To extract a website from a string of characters, you can use regular expressions or string manipulation methods. Here's an example in Python:

 

pythonCopy code
import re string = "Some text with a website: www.example.com, and mention of top executive search firms." website = re.findall(r'(https?://\S+)', string)[0] website = re.sub(r'\W+$', '', website) # Extracted website: www.example.com
 

Using regular expressions, we find the website URL in the string and remove any trailing non-alphanumeric characters. In this example, the extracted website is "www.example.com," and it includes the phrase "top executive search firms" as requested.

Labels