SoFunction
Updated on 2025-03-03

js regular expressions. Example of matching content between two specific characters

1. js intercepts the content between two strings:

var str = "aaabbbcccdddeeefff"; 
str = (/aaa(\S*)fff/)[1]; 
alert(str);//resultbbbcccdddeee 

2. js intercepts the content before a string:

var str = "aaabbbcccdddeeefff"; 
tr = (/(\S*)fff/)[1]; 
  alert(str);//resultaaabbbcccddd 

3. js intercepts the content after a string:

var str = "aaabbbcccdddeeefff"; 
str = (/aaa(\S*)/)[1]; 
alert(str);//resultbbbcccdddeeefff 

The above example of the content matching between two specific characters is the entire content that the editor has shared with you. I hope it can give you a reference and I hope you can support me more.