perl条件正则表达式检查

时间:2018-01-16 13:45:01

标签: regex perl

<project name="kernel/lk" path="bootable/bootloader/lk" revision="e48c9314142c2ae93619ccd14aba2bc975165ffd"/>
<Project name="device/google/contexthub" revision="c453c8b8fb25fb8e1c59e8288331a70dbff44061" />

我在文件中有两行。 我需要获取路径和修订版,如果路径在行中不可用,则必须将名称和修订版作为输出并保存在文件中

  

预期产出:

name="kernel/lk" , revision="e48c9314142c2ae93619ccd14aba2bc975165ffd"
path="device/google/contexthub" , revision="c453c8b8fb25fb8e1c59e8288331a70dbff44061"

如果有人给我代码片段,那将会很有帮助。

1 个答案:

答案 0 :(得分:-1)

if($ row = ~m / name =“(。+?)”\ spath =“(。+?)”\ srevision =“(。+?)”/ g) { 打印“$ 1 $ 3 \ n”; onVerificationCompleted() } PhoneAuthProvider.getInstance().verifyPhoneNumber(mobileNumber, 60, TimeUnit.SECONDS, FirebasePhoneAuthActivity.this, new PhoneAuthProvider.OnVerificationStateChangedCallbacks() { @Override public void onVerificationCompleted(PhoneAuthCredential phoneAuthCredential) { smsCode = phoneAuthCredential.getSmsCode(); Log.i(TAG, "onVerificationCompleted: CODE " + smsCode); Log.i(TAG, "onVerificationCompleted: PROVIDER " + phoneAuthCredential.getProvider()); } @Override public void onVerificationFailed(FirebaseException e) { e.printStackTrace(); } @Override public void onCodeSent(String s, PhoneAuthProvider.ForceResendingToken forceResendingToken) { Log.i(TAG, "onCodeSent: CODE " + s); } @Override public void onCodeAutoRetrievalTimeOut(String s) { super.onCodeAutoRetrievalTimeOut(s); Log.i(TAG, "onCodeAutoRetrievalTimeOut: " + s); } }); elsif($ row = ~m / name =“(。+?)”\ srevision =“(。+?)”/ g) {test 打印“$ 1 $ 2 \ n”; } } enter code here