Regular expression – how to modify IP: PORT regular expressions?

I have normal expressions

match = re.findall(r'[0-9]+(? :\.[0-9]+){3}', source)

It can get content similar to 192.168.1.1 from the source string.
How do I modify this regular expression to make It applies to things like this:

192.168.1.1:80

Thank you for your help.

P.S. Sorry, I English is not good.

This will match the IP address with the port number.

match = re.findall(r'[0-9]+(?:\.[0-9]+){3}:[0-9]+', source)

If you want to match the IP address flexibly without ports and ports, you can use:

match = re.findall( r'[0-9]+(?:\.[0-9]+){3}(:[0-9]+)?', source)

< p>I have a normal expression

match = re.findall(r'[0-9]+(?:\.[0-9]+ ){3}', source)

It can get something like 192.168.1.1 from the source string.
How do I modify this regular expression to make it suitable for things like this:

p>

192.168.1.1:80

Thank you for your help.

Attachment: Sorry, my English is not good.

This will match the IP address with the port number.

match = re.findall(r'[ 0-9]+(?:\.[0-9]+){3}:[0-9]+', source)

If you want to be flexible without ports and ports To match the IP address, you can use:

match = re.findall(r'[0-9]+(?:\.[0-9]+){ 3)( :[0-9]+)?', source)

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 5438 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.