The problem of string segmentation and extraction

excuse me, there is a string as follows, with the offline at the beginning and the mysql.dba.com.lan at the end. It will not change, but the xxx.yyy.zzz in the middle is uncertain. How to intercept the xxx.yyy.zzz, no matter whether the middle part is xxx, xxx.yyy or xxx.yyy.zzz

offline.xxx.yyy.zzz.mysql.dba.com.lan.
Jun.16,2022

if '.mysql.dba.com.lan.' exists in the middle. String, str.replace ('offline.',') .replace ('.mysql.dba.com.lan.,') this method will have a problem.

the same problem exists with the clumsy method, which is changed to str.substring (8 grade str.lastIndexOf ('.mysql.dba.com.lan.)) Just do it.

regular spicy is still great.


regular is the most convenient

'offline.xxx.yyy.zzz.mysql.dba.com.lan.'.match(/offline\.(.+)\.mysql\.dba\.com\.lan\./)

var res = str.replace ('offline.',''). Replace ('.mysql.dba.com.lan.,')


regular is not very good, use stupid method

var str = "offline.xxx.yyy.mysql.dba.com.lan.";
var result = str.substring(8,str.indexOf('.mysql.dba.com.lan.'))
console.log(result) // xxx.yyy
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea1eb1-1b95.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea1eb1-1b95.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?