It mainly involves the special characters of "\" in javascript. Should regular expressions be used?
<script>
var m="D:\Picture\Beggar Gang.jpg"
//Solve Solve
</script>
I hope the value I can get is "Beggars' Sect"
<script type="text/javascript">
var s ="D:\\Picture\\Beggar Gang.jpg";
var t = (/\\([^\\^.]+)\.[^\\]*$/)[1];
alert(t);
</script>
<script>
var m="D:\Picture\Beggar Gang.jpg"
//Solve Solve
</script>
I hope the value I can get is "Beggars' Sect"
Copy the codeThe code is as follows:
<script type="text/javascript">
var s ="D:\\Picture\\Beggar Gang.jpg";
var t = (/\\([^\\^.]+)\.[^\\]*$/)[1];
alert(t);
</script>