我无法找到 reg-exp 来查找 txt 文件中的项目(下面以粗体斜体标记)

发布于 2024-10-31 02:50:08 字数 3848 浏览 5 评论 0原文

------------------------------------------------------------------------------------- Suds ( https://fedorahosted.org/suds/ )  version: 0.3.9 (beta)  build: R658-20100210

Service ( ndfdXML ) tns="http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl" Prefixes (2)
      ns0 = "http://schemas.xmlsoap.org/soap/encoding/"
      ns1 = "http://www.weather.gov/forecasts/xml/DWMLgen/schema/DWML.xsd" Ports (1):
      (ndfdXMLPort)
         Methods (12):
            ***CornerPoints***(ns1:sectorType sector, )
            ***GmlLatLonList***(ns1:listLatLonType listLatLon, xs:dateTime requestedTime, ns1:featureTypeType featureType, ns1:weatherParametersType weatherParameters, )
            ***GmlTimeSeries***(ns1:listLatLonType listLatLon, xs:dateTime startTime, xs:dateTime endTime, ns1:compTypeType compType, ns1:featureTypeType featureType, xs:string propertyName, )
            ***LatLonListCityNames***(ns1:displayLevelType displayLevel, )
            ***LatLonListLine***(xs:decimal endPoint1Lat, xs:decimal endPoint1Lon, xs:decimal endPoint2Lat, xs:decimal endPoint2Lon, )
            ***LatLonListSquare***(xs:decimal centerPointLat, xs:decimal centerPointLon, xs:decimal distanceLat, xs:decimal distanceLon, xs:decimal resolution, )
            ***LatLonListSubgrid***(xs:decimal lowerLeftLatitude, xs:decimal lowerLeftLongitude, xs:decimal upperRightLatitude, xs:decimal upperRightLongitude, xs:decimal resolution, )
            ***LatLonListZipCode***(ns1:zipCodeListType zipCodeList, )
            **NDFDgen**(xs:decimal latitude, xs:decimal longitude, ns1:productType product, xs:dateTime startTime, xs:dateTime endTime, ns1:weatherParametersType weatherParameters, )
            ***NDFDgenByDay***(xs:decimal latitude, xs:decimal longitude, xs:date startDate, xs:integer numDays, ns1:formatType format, )
            ***NDFDgenByDayLatLonList***(ns1:listLatLonType listLatLon, xs:date startDate, xs:integer numDays, ns1:formatType format, )
            ***NDFDgenLatLonList***(ns1:listLatLonType listLatLon, ns1:productType product, xs:dateTime startTime, xs:dateTime endTime, ns1:weatherParametersType weatherParameters, )
         Types (60):
            ns0:Array
            ns0:ENTITIES
            ns0:ENTITY
            ns0:ID
            ns0:IDREF
            ns0:IDREFS
            ns0:NCName
            ns0:NMTOKEN
            ns0:NMTOKENS
            ns0:NOTATION
            ns0:Name
            ns0:QName
            ns0:Struct
            ns0:anyURI
            ns0:arrayCoordinate
            ns0:base64
            ns0:base64Binary
            ns0:boolean
            ns0:byte
            ns1:compTypeType
            ns0:date
            ns0:dateTime
            ns0:decimal
            ns1:displayLevelType
            ns0:double
            ns0:duration
            ns1:featureTypeType
            ns0:float
            ns1:formatType
            ns0:gDay
            ns0:gMonth
            ns0:gMonthDay
            ns0:gYear
            ns0:gYearMonth
            ns0:hexBinary
            ns0:int
            ns0:integer
            ns0:language
            ns1:latLonPairType
            ns1:listCityNamesType
            ns1:listLatLonType
            ns0:long
            ns0:negativeInteger
            ns0:nonNegativeInteger
            ns0:nonPositiveInteger
            ns0:normalizedString
            ns0:positiveInteger
            ns1:productType
            ns1:sectorType
            ns0:short
            ns0:string
            ns0:time
            ns0:token
            ns0:unsignedByte
            ns0:unsignedInt
            ns0:unsignedLong
            ns0:unsignedShort
            ns1:weatherParametersType
            ns1:zipCodeListType
            ns1:zipCodeType
-------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------- Suds ( https://fedorahosted.org/suds/ )  version: 0.3.9 (beta)  build: R658-20100210

Service ( ndfdXML ) tns="http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl" Prefixes (2)
      ns0 = "http://schemas.xmlsoap.org/soap/encoding/"
      ns1 = "http://www.weather.gov/forecasts/xml/DWMLgen/schema/DWML.xsd" Ports (1):
      (ndfdXMLPort)
         Methods (12):
            ***CornerPoints***(ns1:sectorType sector, )
            ***GmlLatLonList***(ns1:listLatLonType listLatLon, xs:dateTime requestedTime, ns1:featureTypeType featureType, ns1:weatherParametersType weatherParameters, )
            ***GmlTimeSeries***(ns1:listLatLonType listLatLon, xs:dateTime startTime, xs:dateTime endTime, ns1:compTypeType compType, ns1:featureTypeType featureType, xs:string propertyName, )
            ***LatLonListCityNames***(ns1:displayLevelType displayLevel, )
            ***LatLonListLine***(xs:decimal endPoint1Lat, xs:decimal endPoint1Lon, xs:decimal endPoint2Lat, xs:decimal endPoint2Lon, )
            ***LatLonListSquare***(xs:decimal centerPointLat, xs:decimal centerPointLon, xs:decimal distanceLat, xs:decimal distanceLon, xs:decimal resolution, )
            ***LatLonListSubgrid***(xs:decimal lowerLeftLatitude, xs:decimal lowerLeftLongitude, xs:decimal upperRightLatitude, xs:decimal upperRightLongitude, xs:decimal resolution, )
            ***LatLonListZipCode***(ns1:zipCodeListType zipCodeList, )
            **NDFDgen**(xs:decimal latitude, xs:decimal longitude, ns1:productType product, xs:dateTime startTime, xs:dateTime endTime, ns1:weatherParametersType weatherParameters, )
            ***NDFDgenByDay***(xs:decimal latitude, xs:decimal longitude, xs:date startDate, xs:integer numDays, ns1:formatType format, )
            ***NDFDgenByDayLatLonList***(ns1:listLatLonType listLatLon, xs:date startDate, xs:integer numDays, ns1:formatType format, )
            ***NDFDgenLatLonList***(ns1:listLatLonType listLatLon, ns1:productType product, xs:dateTime startTime, xs:dateTime endTime, ns1:weatherParametersType weatherParameters, )
         Types (60):
            ns0:Array
            ns0:ENTITIES
            ns0:ENTITY
            ns0:ID
            ns0:IDREF
            ns0:IDREFS
            ns0:NCName
            ns0:NMTOKEN
            ns0:NMTOKENS
            ns0:NOTATION
            ns0:Name
            ns0:QName
            ns0:Struct
            ns0:anyURI
            ns0:arrayCoordinate
            ns0:base64
            ns0:base64Binary
            ns0:boolean
            ns0:byte
            ns1:compTypeType
            ns0:date
            ns0:dateTime
            ns0:decimal
            ns1:displayLevelType
            ns0:double
            ns0:duration
            ns1:featureTypeType
            ns0:float
            ns1:formatType
            ns0:gDay
            ns0:gMonth
            ns0:gMonthDay
            ns0:gYear
            ns0:gYearMonth
            ns0:hexBinary
            ns0:int
            ns0:integer
            ns0:language
            ns1:latLonPairType
            ns1:listCityNamesType
            ns1:listLatLonType
            ns0:long
            ns0:negativeInteger
            ns0:nonNegativeInteger
            ns0:nonPositiveInteger
            ns0:normalizedString
            ns0:positiveInteger
            ns1:productType
            ns1:sectorType
            ns0:short
            ns0:string
            ns0:time
            ns0:token
            ns0:unsignedByte
            ns0:unsignedInt
            ns0:unsignedLong
            ns0:unsignedShort
            ns1:weatherParametersType
            ns1:zipCodeListType
            ns1:zipCodeType
-------------------------------------------------------------------------------------------

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

倾城月光淡如水﹏ 2024-11-07 02:50:08
import re
text='''Service ( ndfdXML ) tns="http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl" Prefixes (2) ns0 = "http://schemas.xmlsoap.org/soap/encoding/" ns1 = "http://www.weather.gov/forecasts/xml/DWMLgen/schema/DWML.xsd" Ports (1): (ndfdXMLPort) Methods (12): CornerPoints(ns1:sectorType sector, ) GmlLatLonList(ns1:listLatLonType listLatLon, xs:dateTime requestedTime, ns1:featureTypeType featureType, ns1:weatherParametersType weatherParameters, ) GmlTimeSeries(ns1:listLatLonType listLatLon, xs:dateTime startTime, xs:dateTime endTime, ns1:compTypeType compType, ns1:featureTypeType featureType, xs:string propertyName, ) LatLonListCityNames(ns1:displayLevelType displayLevel, ) LatLonListLine(xs:decimal endPoint1Lat, xs:decimal endPoint1Lon, xs:decimal endPoint2Lat, xs:decimal endPoint2Lon, ) LatLonListSquare(xs:decimal centerPointLat, xs:decimal centerPointLon, xs:decimal distanceLat, xs:decimal distanceLon, xs:decimal resolution, ) LatLonListSubgrid(xs:decimal lowerLeftLatitude, xs:decimal lowerLeftLongitude, xs:decimal upperRightLatitude, xs:decimal upperRightLongitude, xs:decimal resolution, ) LatLonListZipCode(ns1:zipCodeListType zipCodeList, ) NDFDgen(xs:decimal latitude, xs:decimal longitude, ns1:productType product, xs:dateTime startTime, xs:dateTime endTime, ns1:weatherParametersType weatherParameters, ) NDFDgenByDay(xs:decimal latitude, xs:decimal longitude, xs:date startDate, xs:integer numDays, ns1:formatType format, ) NDFDgenByDayLatLonList(ns1:listLatLonType listLatLon, xs:date startDate, xs:integer numDays, ns1:formatType format, ) NDFDgenLatLonList(ns1:listLatLonType listLatLon, ns1:productType product, xs:dateTime startTime, xs:dateTime endTime, ns1:weatherParametersType weatherParameters, ) Types (60): ns0:Array ns0:ENTITIES ns0:ENTITY ns0:ID ns0:IDREF ns0:IDREFS ns0:NCName ns0:NMTOKEN ns0:NMTOKENS ns0:NOTATION ns0:Name ns0:QName ns0:Struct ns0:anyURI ns0:arrayCoordinate ns0:base64 ns0:base64Binary ns0:boolean ns0:byte ns1:compTypeType ns0:date ns0:dateTime ns0:decimal ns1:displayLevelType ns0:double ns0:duration ns1:featureTypeType ns0:float ns1:formatType ns0:gDay ns0:gMonth ns0:gMonthDay ns0:gYear ns0:gYearMonth ns0:hexBinary ns0:int ns0:integer ns0:language ns1:latLonPairType ns1:listCityNamesType ns1:listLatLonType ns0:long ns0:negativeInteger ns0:nonNegativeInteger ns0:nonPositiveInteger ns0:normalizedString ns0:positiveInteger ns1:productType ns1:sectorType ns0:short ns0:string ns0:time ns0:token ns0:unsignedByte ns0:unsignedInt ns0:unsignedLong ns0:unsignedShort ns1:weatherParametersType ns1:zipCodeListType'''

for match in re.findall(r"[a-zA-Z]+?\s*\([a-z]*?[0-9]*?:",text):
    print match.split("(")[0]
import re
text='''Service ( ndfdXML ) tns="http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl" Prefixes (2) ns0 = "http://schemas.xmlsoap.org/soap/encoding/" ns1 = "http://www.weather.gov/forecasts/xml/DWMLgen/schema/DWML.xsd" Ports (1): (ndfdXMLPort) Methods (12): CornerPoints(ns1:sectorType sector, ) GmlLatLonList(ns1:listLatLonType listLatLon, xs:dateTime requestedTime, ns1:featureTypeType featureType, ns1:weatherParametersType weatherParameters, ) GmlTimeSeries(ns1:listLatLonType listLatLon, xs:dateTime startTime, xs:dateTime endTime, ns1:compTypeType compType, ns1:featureTypeType featureType, xs:string propertyName, ) LatLonListCityNames(ns1:displayLevelType displayLevel, ) LatLonListLine(xs:decimal endPoint1Lat, xs:decimal endPoint1Lon, xs:decimal endPoint2Lat, xs:decimal endPoint2Lon, ) LatLonListSquare(xs:decimal centerPointLat, xs:decimal centerPointLon, xs:decimal distanceLat, xs:decimal distanceLon, xs:decimal resolution, ) LatLonListSubgrid(xs:decimal lowerLeftLatitude, xs:decimal lowerLeftLongitude, xs:decimal upperRightLatitude, xs:decimal upperRightLongitude, xs:decimal resolution, ) LatLonListZipCode(ns1:zipCodeListType zipCodeList, ) NDFDgen(xs:decimal latitude, xs:decimal longitude, ns1:productType product, xs:dateTime startTime, xs:dateTime endTime, ns1:weatherParametersType weatherParameters, ) NDFDgenByDay(xs:decimal latitude, xs:decimal longitude, xs:date startDate, xs:integer numDays, ns1:formatType format, ) NDFDgenByDayLatLonList(ns1:listLatLonType listLatLon, xs:date startDate, xs:integer numDays, ns1:formatType format, ) NDFDgenLatLonList(ns1:listLatLonType listLatLon, ns1:productType product, xs:dateTime startTime, xs:dateTime endTime, ns1:weatherParametersType weatherParameters, ) Types (60): ns0:Array ns0:ENTITIES ns0:ENTITY ns0:ID ns0:IDREF ns0:IDREFS ns0:NCName ns0:NMTOKEN ns0:NMTOKENS ns0:NOTATION ns0:Name ns0:QName ns0:Struct ns0:anyURI ns0:arrayCoordinate ns0:base64 ns0:base64Binary ns0:boolean ns0:byte ns1:compTypeType ns0:date ns0:dateTime ns0:decimal ns1:displayLevelType ns0:double ns0:duration ns1:featureTypeType ns0:float ns1:formatType ns0:gDay ns0:gMonth ns0:gMonthDay ns0:gYear ns0:gYearMonth ns0:hexBinary ns0:int ns0:integer ns0:language ns1:latLonPairType ns1:listCityNamesType ns1:listLatLonType ns0:long ns0:negativeInteger ns0:nonNegativeInteger ns0:nonPositiveInteger ns0:normalizedString ns0:positiveInteger ns1:productType ns1:sectorType ns0:short ns0:string ns0:time ns0:token ns0:unsignedByte ns0:unsignedInt ns0:unsignedLong ns0:unsignedShort ns1:weatherParametersType ns1:zipCodeListType'''

for match in re.findall(r"[a-zA-Z]+?\s*\([a-z]*?[0-9]*?:",text):
    print match.split("(")[0]
亽野灬性zι浪 2024-11-07 02:50:08

您想要一个可以找到所有这些的正则表达式,还是每个都可以找到一个?你需要返回什么数据(我假设是 () 的内容和对象名称)?

从你所拥有的猜测,我假设这样的事情可以工作:

((CornerPoints|LatLonListZipCode|other|names)\(.*\)))

它将匹配前半部分中的一个名称,然后是它后面的一个 (data) 组(你可能想让它成为非-贪婪的)。

如果您编辑问题或评论以提供更多信息,我将编辑答案。

Do you want a regex that finds all of them, or one for each? What data do you need back (I assume the contents of the () and object name)?

Guessing from what you have, I assume something like this could work:

((CornerPoints|LatLonListZipCode|other|names)\(.*\)))

That will match one of the names in the first half, then a (data) group after it (you may want to make it non-greedy).

If you edit the question or comment with more info, I'll edit the answer.

所谓喜欢 2024-11-07 02:50:08

@peachykeen:是的,它必须是非贪婪的,否则 .* 会一直竞争到字符串中的最后一个 ')' 。您还需要匹配组,最好是命名的,以便引用您匹配的内容:

/(?P<key>name1|name2|...)(?P<value>\(.*?\))/

@peachykeen: yes it needs to be non greedy,otherwise the .* races all the way to the very last ')' in the string. You also need match groups, preferably named, in order to refer to what you matched:

/(?P<key>name1|name2|...)(?P<value>\(.*?\))/
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文