我有这个字符串:
“ lorem ipsum例如,这是^一些要使用的文本^”
我怎样才能只获得以^开头和结尾的单词?
所以结果应该是:“一些要使用的文字”
使用C#正则表达式或其他任何方式。
答案 0 :(得分:1)
<ng-progress #progressBar (started)="onStarted()" (completed)="onCompleted()"
[color]="options.color"
[speed]="options.speed"
[spinner]="options.spinner"
[spinnerPosition]="options.spinnerPosition"
[trickleSpeed]="options.trickleSpeed"
[ease]="options.ease">
</ng-progress>
<button (click)="testHttp()">hihihihi
</button>
import { NgProgress } from '@ngx-progressbar/core';
startedClass = false;
completedClass = false;
options = {
minimum: 0.08,
maximum: 1,
ease: 'linear',
speed: 200,
trickleSpeed: 300,
meteor: true,
spinner: true,
spinnerPosition: 'right',
direction: 'leftToRightIncreased',
color: 'red',
thick: true
};
onStarted() {
this.startedClass = true;
setTimeout(() => {
this.startedClass = false;
}, 800);
}
onCompleted() {
this.completedClass = true;
setTimeout(() => {
this.completedClass = false;
}, 800);
}
testHttp() {
this.http.get('https://reqres.in/api/usersdelay=2').subscribe(res => {
console.log(res);
});
}
constructor(public router: Router ,private http: Http ,public progress: NgProgress) { }
将为您提供: ^一些要使用的文字^
Regex.Match(s, @"\^.+\^").Value
将为您提供:一些要使用的文字
答案 1 :(得分:0)
尝试一下:
<a class="thirdbox"
href="/media/wysiwyg/pdf/systemaufbau-anleitungen.pdf"
target="_blank" download="blizz-z_Systemaufbau_Anleitungen" title="Datei downloaden">...</a>
↑
Problem
\^\K\b[^\^]+
=“一些要使用的文字”
如果您有一场比赛-您不需要分组。如果只有一个,则必须使用组。
答案 2 :(得分:0)
这种方法比Regex更好。 字符串类为您提供了获取所需内容的方法。 另外,无需使用模式来污染代码
尝试一下:
SUMIFS
答案 3 :(得分:0)
尝试一下
(?<=\^\s*).+(?=\s*\^)
这将为您提供结果,但不包括^符号
some text to use
如果有帮助,请不要忘记投票。