从变量中选择变量中的字符串。 [英] select string in variable from variable.
问题描述
Hi Folks
我在从数组中选择字符串时遇到问题。
I'm having an issue selecting a string from an array.
我有一个文件"A"数据类似于belew
I have a File "A" with data similar to belew
[BornPlace0] 1 3000 136669 26640 1 1000 200 0 0 0 5000 50 0 0 0 0 0 3.8 0 0 0 0 0
[BornPlace1] 1 3000 119248 37216 1 1000 200 0 0 0 5000 50 0 0 0 0 0 3.8 0 0 0 0 0 0 $
[ BornPlace2] 1 3000 175195 71315 1 1000 200 0 0 0 5000 50 0 0 0 0 0 3.8 0 0 0 0 0 0 $
[BornPlace3] 1 3000 161795 67096 1 1000 200 0 0 0 5000 50 0 0 0 0 0 3.8 0 0 0 0 0 0 $
[BornPlace4] 1 3000 162507 102132 1 1000 200 0 0 0 5000 50 0 0 0 0 0 3.8 0 0 0 0 0
[BornPlace5] 1 3000 175589 138093 1 1000 200 0 0 0 5000 50 0 0 0 0 0 3.8 0 0 0 0 0 0 $
[BornPlace6] 1 3000 125901 129376 1 1000 200 0 0 0 5000 50 0 0 0 0 0 3.8 0 0 0 0 0
$
[BornPlace7] 1 3000 121895 151749 1 1000 200 0 0 0 5000 50 0 0 0 0 0 3.8 0 0 0 0 0 0
[BornPlace8] 1 3000 87523 23310 1 1000 200 0 0 0 5000 50 0 0 0 0 0 3.8 0 0 0 0 0 0
  ; [BornPlace9] 1 3000 32730 24390 1 1000 200 0 0 0 5000 50 0 0 0 0 0 3.8 0 0 0 0 0
$
[BornPlace10] 1 3000 44069 57505 1 1000 200 0 0 0 5000 50 0 0 0 0 0 3.8 0 0 0 0 0
¥b $ b [BornPlace11] 1 3000 91669 46262 1 1000 200 0 0 0 5000 50 0 0 0 0 0 3.8 0 0 0 0 0
$
[BornPlace13] 1 3000 121244 74170 1 1000 200 0 0 0 5000 50 0 0 0 0 0 3.8 0 0 0 0 0
[BornPlace0] 1 3000 136669 26640 1 1000 200 0 0 0 5000 50 0 0 0 0 0 3.8 0 0 0 0 0
[BornPlace1] 1 3000 119248 37216 1 1000 200 0 0 0 5000 50 0 0 0 0 0 3.8 0 0 0 0 0
[BornPlace2] 1 3000 175195 71315 1 1000 200 0 0 0 5000 50 0 0 0 0 0 3.8 0 0 0 0 0
[BornPlace3] 1 3000 161795 67096 1 1000 200 0 0 0 5000 50 0 0 0 0 0 3.8 0 0 0 0 0
[BornPlace4] 1 3000 162507 102132 1 1000 200 0 0 0 5000 50 0 0 0 0 0 3.8 0 0 0 0 0
[BornPlace5] 1 3000 175589 138093 1 1000 200 0 0 0 5000 50 0 0 0 0 0 3.8 0 0 0 0 0
[BornPlace6] 1 3000 125901 129376 1 1000 200 0 0 0 5000 50 0 0 0 0 0 3.8 0 0 0 0 0
[BornPlace7] 1 3000 121895 151749 1 1000 200 0 0 0 5000 50 0 0 0 0 0 3.8 0 0 0 0 0
[BornPlace8] 1 3000 87523 23310 1 1000 200 0 0 0 5000 50 0 0 0 0 0 3.8 0 0 0 0 0
[BornPlace9] 1 3000 32730 24390 1 1000 200 0 0 0 5000 50 0 0 0 0 0 3.8 0 0 0 0 0
[BornPlace10] 1 3000 44069 57505 1 1000 200 0 0 0 5000 50 0 0 0 0 0 3.8 0 0 0 0 0
[BornPlace11] 1 3000 91669 46262 1 1000 200 0 0 0 5000 50 0 0 0 0 0 3.8 0 0 0 0 0
[BornPlace13] 1 3000 121244 74170 1 1000 200 0 0 0 5000 50 0 0 0 0 0 3.8 0 0 0 0 0
然后我提交"B"有上述字符串之一,但没有[Bornplace]信息
I then file "B" that has one of the above strings but without the [Bornplace] info
示例:
1 3000 162507 102132 1 1000 200 0 0 0 5000 50 0 0 0 0 0 3.8 0 0 0 0 0
1 3000 162507 102132 1 1000 200 0 0 0 5000 50 0 0 0 0 0 3.8 0 0 0 0 0
我要做的是将文件B字符串与文件A匹配,但我只想得到[ Bornplace]与文件B字符串匹配的信息。
What I'm trying to do is take File B string and match it to file A but I'd like to only get the [Bornplace] info that matches file B String.
所以如果我正在搜索1 3000 162507 102132 1 1000 200 0 0 0 5000 50 0 0 0 0 0 3.8 0 0 0 0 0 id就像返回信息一样[BornPlace4]
so if im doing a search on 1 3000 162507 102132 1 1000 200 0 0 0 5000 50 0 0 0 0 0 3.8 0 0 0 0 0 id like the return info to be [BornPlace4]
任何人都可以对命令进行任何说明以获取数据?
Could anyone shed any light on the command to pull that data?
我很欣赏这看起来非常简单,但我已经尝试了一天没有任何结果。 : - (
I appreciate this looks very simple but I've tried for a fiew days without any results. :-(
推荐答案
使用get-content命令添加分配给变量的文件
just to add File a assigned to the variable
A.
文件B也设置为
B变量,这可能是我遇到问题的部分原因。
B variable, this might be part of the reason I'm having issues.
这篇关于从变量中选择变量中的字符串。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!