import java.io.FileNotFoundException
import java.util.Scanner
public class Readtxt {
public static void main(String[] args) {
try {
Scanner in = new Scanner(new File("d:/abc.txt"))
while (in.hasNextLine()) {
String str = in.nextLine()
splitt(str)
}
} catch (FileNotFoundException e) {
e.printStackTrace()
}
}
public static String[] splitt(String str){
String strr = str.trim()
String[] abc = strr.split("[\\p{Space}]+")
String str1 = abc[0]
String str2 = abc[1]
System.out.println(str1)
System.out.println(str2)
return abc
}
}
这个方法可以读到后台,然后再传到前台就可以了
//函数需要传一个this进去 在你现在的input里面写成:// <input type="text" name="pinpai" id="mytext" value onkeydown="controlLen(this)" />
function controlLen(elem){
var reg=/(最便宜|最好)/g
elem.value.match(reg)!=-1&&alert('您不能使用 '+elem.value.match(reg)[0] +' 这种语言来发布信息!')
}
js:
function beforeSubmit(form){return confirm('提交数量为 ' + form.num.value + ' ?')
}
html:
<form onsubmit="return beforeSubmit(this)"><input type="text" name="num"/>
<button type="submit">submit</button>
</form>