我有这种格式的数据:
MainCode|SideCode|Family.
实际数据如下所示
990337|6953 |REGULAR_ENTREE
990337|990274|REGULAR_ENTREE
8287 |5 |REGULAR_ENTREE
8287 |8266 |FRIES
990337|6953 |REGULAR_ENTREE
990337|990274|REGULAR_ENTREE/BF_ENTREE
如果两个家庭相似(在这种情况下我们同时为" ENTREES"),我不必阅读主要项目代码(990337)。所有这些值都只是字符串。
8287|5 |REGULAR_ENTREE
8287|8266|FRIES
如果两个家庭不同(在这种情况下我们同时为" REGULAR_ENTREE"和" FRIES"),我需要阅读主要项目代码(8287)。所有这些值都只是字符串。
任何人都可以帮我找到解决方案。
答案 0 :(得分:0)
根据您的描述,听起来您将一次处理两个条目,然后在进行进一步处理之前比较字符串以某种方式确定“相似性”。
假设您的输入总是以这种方式输入,您可以拆分“|”将您的条目分成两个数组的字符,如下所示:
String[] entryA = "990337|6953|REGULAR_ENTREE".split("|");
String[] entryB = "990337|990274|REGULAR_ENTREE/BF_ENTREE".split("|");
然后你可以在确定你是否关心将在entryA [0]中的“主项目代码”之前检查entryA [2]对entryB [2]的相似性(你如何确定你的问题中的相似性不清楚)和entryB [0]。
答案 1 :(得分:0)
如果是100%ENTREE,你可以比较部分字符串,你可能会做这样的事情。不确定这是否是最好的方法。或者你可以做一些像正则表达式来比较字符串
@echo off
:questions
cls
set /p start=[Shutdown time (The hour of shutdown, do not add minutes):]
set /p 1ampm=[am/pm:]
cls
set /p end=[Enter the time you want the computer to be available again for use(The hour of shutdown, do not add minutes):]
set /p 2ampm=[am/pm:]
cls
echo Loading....
PING 1.1.1.1 -n 1 -w 2000 >NUL
cls
set /p yesno=[The time you selected the computer to remain off is from %start% - %end% , is this correct, y/n?]
cls
goto :yn
:yn
if %yesno% EQU y (
goto :1timecorrect
) if %yesno% EQU n (
goto :questions
) else (
goto :questions
)
:1timecorrect
if %1ampm% EQU am (
goto :2timecorrect
) if %1ampm% EQU pm (
set realstart=%start%+12
goto :2timecorrect
) else (
cls
echo you did not enter whether or not the start time is am or pm
goto :questions
)
:2timecorrect
if %2ampm% EQU am (
goto :Begining
) if %2ampm% EQU pm (
set realend=%end%+12
goto :Begining
) else (
cls
echo you did not enter whether or not the start time is am or pm
goto :questions
)
:Begining
set mytime=%time:~0,2%
:Start
if %mytime% GEQ %realstart% (
cls
echo time has expired, time to go to bed.
shutdown -s -f -t 60 -c "Your computer is about to be shut down in 1 minute"
) else (
if %mytime% LEQ %realend% (
echo time has expired, time to go to bed.
shutdown -s -f -t 60 -c "Your computer is about to be shut down in 1 minute"
) else (
cls
echo This program is Opperating correctly
PING 1.1.1.1 -n 1 -w 600000 >NUL
goto :Start
)
)